start building pieces of the test data set for full resolve.
This commit is contained in:
parent
b335c14b7b
commit
78715bc128
6 changed files with 34 additions and 34 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
dbpkg "github.com/lbryio/hub/db"
|
dbpkg "github.com/lbryio/hub/db"
|
||||||
"github.com/lbryio/hub/db/prefixes"
|
"github.com/lbryio/hub/db/prefixes"
|
||||||
|
"github.com/lbryio/lbry.go/v2/extras/util"
|
||||||
"github.com/linxGnu/grocksdb"
|
"github.com/linxGnu/grocksdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -282,7 +283,7 @@ func TestOpenFullDB(t *testing.T) {
|
||||||
|
|
||||||
// FIXME: Needs new data format
|
// FIXME: Needs new data format
|
||||||
func TestResolve(t *testing.T) {
|
func TestResolve(t *testing.T) {
|
||||||
filePath := "../testdata/P_cat.csv"
|
filePath := "../testdata/P_resolve.csv"
|
||||||
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
|
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -414,19 +415,20 @@ func TestGetTXOToClaim(t *testing.T) {
|
||||||
|
|
||||||
// TestPrintClaimToTXO Utility function to cat the ClaimToTXO csv.
|
// TestPrintClaimToTXO Utility function to cat the ClaimToTXO csv.
|
||||||
func TestPrintClaimToTXO(t *testing.T) {
|
func TestPrintClaimToTXO(t *testing.T) {
|
||||||
filePath := "../testdata/E_2.csv"
|
filePath := "../testdata/E_resolve.csv"
|
||||||
CatCSV(filePath)
|
CatCSV(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGetClaimToTXO Tests getting a ClaimToTXO value from the db.
|
// TestGetClaimToTXO Tests getting a ClaimToTXO value from the db.
|
||||||
func TestGetClaimToTXO(t *testing.T) {
|
func TestGetClaimToTXO(t *testing.T) {
|
||||||
claimHashStr := "00000324e40fcb63a0b517a3660645e9bd99244a"
|
claimHashStr := "2556ed1cab9d17f2a9392030a9ad7f5d138f11bd"
|
||||||
|
want := uint32(0x6284e3)
|
||||||
claimHash, err := hex.DecodeString(claimHashStr)
|
claimHash, err := hex.DecodeString(claimHashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
filePath := "../testdata/E_2.csv"
|
filePath := "../testdata/E_resolve.csv"
|
||||||
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
|
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -438,29 +440,38 @@ func TestGetClaimToTXO(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println(res)
|
if res.TxNum != want {
|
||||||
|
t.Errorf("Expected %d, got %d", want, res.TxNum)
|
||||||
|
}
|
||||||
|
log.Printf("res: %#v\n", res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPrintClaimTakeover Utility function to cat the ClaimTakeover csv.
|
// TestPrintClaimTakeover Utility function to cat the ClaimTakeover csv.
|
||||||
func TestPrintClaimTakeover(t *testing.T) {
|
func TestPrintClaimTakeover(t *testing.T) {
|
||||||
filePath := "../testdata/P_cat.csv"
|
filePath := "../testdata/P_resolve.csv"
|
||||||
CatCSV(filePath)
|
CatCSV(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGetControlingClaim Tests getting a controlling claim value from the db
|
// TestGetControlingClaim Tests getting a controlling claim value from the db
|
||||||
// based on a name.
|
// based on a name.
|
||||||
func TestGetControllingClaim(t *testing.T) {
|
func TestGetControllingClaim(t *testing.T) {
|
||||||
filePath := "../testdata/P_cat.csv"
|
claimName := util.NormalizeName("@Styxhexenhammer666")
|
||||||
|
claimHash := "2556ed1cab9d17f2a9392030a9ad7f5d138f11bd"
|
||||||
|
filePath := "../testdata/P_resolve.csv"
|
||||||
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
|
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer toDefer()
|
defer toDefer()
|
||||||
res, err := dbpkg.GetControllingClaim(db, "cat")
|
res, err := dbpkg.GetControllingClaim(db, claimName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
}
|
||||||
|
|
||||||
|
got := hex.EncodeToString(res.ClaimHash)
|
||||||
|
if claimHash != got {
|
||||||
|
t.Errorf("Expected %s, got %s", claimHash, got)
|
||||||
}
|
}
|
||||||
log.Println(res)
|
log.Println(res)
|
||||||
}
|
}
|
||||||
|
|
13
main.go
13
main.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -110,10 +111,16 @@ func main() {
|
||||||
|
|
||||||
return
|
return
|
||||||
} else if args.CmdType == server.DBCmd3 {
|
} else if args.CmdType == server.DBCmd3 {
|
||||||
// channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
|
channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
|
||||||
var rawPrefix byte = prefixes.DBState
|
// name := util.NormalizeName("@Styxhexenhammer666")
|
||||||
|
var rawPrefix byte = prefixes.ClaimToTXO
|
||||||
|
var startRaw []byte = nil
|
||||||
prefix := []byte{rawPrefix}
|
prefix := []byte{rawPrefix}
|
||||||
columnFamily := string(prefix)
|
columnFamily := string(prefix)
|
||||||
|
// start := prefixes.NewClaimTakeoverKey(name)
|
||||||
|
start := prefixes.NewClaimToTXOKey(channelHash)
|
||||||
|
|
||||||
|
startRaw = start.PackKey()
|
||||||
// start := &prefixes.ChannelCountKey{
|
// start := &prefixes.ChannelCountKey{
|
||||||
// Prefix: prefix,
|
// Prefix: prefix,
|
||||||
// ChannelHash: channelHash,
|
// ChannelHash: channelHash,
|
||||||
|
@ -123,7 +130,7 @@ func main() {
|
||||||
options := &db.IterOptions{
|
options := &db.IterOptions{
|
||||||
FillCache: false,
|
FillCache: false,
|
||||||
Prefix: prefix,
|
Prefix: prefix,
|
||||||
Start: nil,
|
Start: startRaw,
|
||||||
Stop: nil,
|
Stop: nil,
|
||||||
IncludeStart: true,
|
IncludeStart: true,
|
||||||
IncludeStop: false,
|
IncludeStop: false,
|
||||||
|
|
11
testdata/E_2.csv
vendored
11
testdata/E_2.csv
vendored
|
@ -1,11 +0,0 @@
|
||||||
E,,
|
|
||||||
E,45000000a420c44374f4f399ab4807fa1901eefc87,0297ec2100000297ec21000000000000000f42400100246167656e63652d64c3a974727569742c2d6e6f7576656175782d736b696e732d6c65616b
|
|
||||||
E,45000000c27eef5ea69e0d73f118826c7e326bb469,00371d66000000371d660000000000001dcd650001000e4d696e696174757265486f757365
|
|
||||||
E,4500000110e40894573f528c393fbcec7a472ec853,01516b32000001516b3200000000000000989680010021696f2d3137372d4e6f616d2d43686f6d736b792d6f6e2d434f494e54454c50524f
|
|
||||||
E,4500000324e40fcb63a0b517a3660645e9bd99244a,030bb6ba0000030bb6ba000000000000000f424001001b436f6e616e2d4578696c65732d526169642d4561726c792d457261
|
|
||||||
E,45000003d1538a0f19f5cd4bc1a62cc294f5c89934,011c7c990000011c7c99000000000000000f424001001130322d636172726167652d68616e646c65
|
|
||||||
E,45000008d47beeff8325e795a8604226145b01702b,02dbb2a2000002dbb2a2000000000000000186a001001039643336363661336161313231376138
|
|
||||||
E,4500000906499e073e94370ceff37cb21c28212444,0369842d00000369842d000000000000000186a001001033333465356465363139306534323466
|
|
||||||
E,45000009c3172e034a255f3c03566dca84bb9f046a,0225c69c000002251b0f0000000000000007a120010028617574686f722d73746f726965732d706f64636173742d657069736f64652d3734332d6b6172656e
|
|
||||||
E,45000009ca6e0caaaef16872b4bd4f6f1b8c2363e2,02b16956000002b16956000000000000000f4240010027554e2d504f55522d43454e542d28312d292d28536f72616c2c2d4162c3a963c3a9646169726529
|
|
||||||
E,4500000ad9ded2e15d18987900d09e9b29ef33d03e,02c972b3000002c972b3000000000000000186a0010006313331333333
|
|
|
2
testdata/E_resolve.csv
vendored
Normal file
2
testdata/E_resolve.csv
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
E,,
|
||||||
|
E,452556ed1cab9d17f2a9392030a9ad7f5d138f11bd,006284e300000061ec7c0000000000000007a1200000134053747978686578656e68616d6d6572363636
|
|
11
testdata/P_cat.csv
vendored
11
testdata/P_cat.csv
vendored
|
@ -1,11 +0,0 @@
|
||||||
P,,
|
|
||||||
P,500003636174,7b07396275ce6b5fd30bfbc84f69dd7818c4e119000d695f
|
|
||||||
P,500003636176,6950f0e12745c690b28365738e0095c776d48dd2000d7fc0
|
|
||||||
P,50000363617a,9991c150e0e7df76163cbda34bd9bca59cc5a032000c2c3e
|
|
||||||
P,500003636231,3cd83b2b8e06867c3d8b066427896005881c5db9000bb158
|
|
||||||
P,500003636232,e7e1aa9d2e5d7c8e6349f06dfb0ff1fd8e69038f000fdd49
|
|
||||||
P,500003636233,d8d7099f4db8be475ed9e4ee2cd062fb6ce9533e000fc62b
|
|
||||||
P,500003636234,b696eb09a7529365015a033ebf4708101a1e1313000f17dd
|
|
||||||
P,500003636235,33b755873917f6c6d78a3777c3828827cc3a1e7e000fc68e
|
|
||||||
P,500003636236,ec06a840aaa04c2c09cc7f0b122ac3bbc2697e5b000fd4e8
|
|
||||||
P,500003636237,e1d0cdb9bd6f230f2d0eb860f1d634c737c52c95000f006d
|
|
|
2
testdata/P_resolve.csv
vendored
Normal file
2
testdata/P_resolve.csv
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
P,,
|
||||||
|
P,5000134073747978686578656e68616d6d6572363636,2556ed1cab9d17f2a9392030a9ad7f5d138f11bd000a6471
|
|
Loading…
Reference in a new issue