start building pieces of the test data set for full resolve.

This commit is contained in:
Jeffrey Picard 2022-02-22 07:22:00 -05:00
parent b335c14b7b
commit 78715bc128
6 changed files with 34 additions and 34 deletions

View file

@ -10,6 +10,7 @@ import (
dbpkg "github.com/lbryio/hub/db"
"github.com/lbryio/hub/db/prefixes"
"github.com/lbryio/lbry.go/v2/extras/util"
"github.com/linxGnu/grocksdb"
)
@ -282,7 +283,7 @@ func TestOpenFullDB(t *testing.T) {
// FIXME: Needs new data format
func TestResolve(t *testing.T) {
filePath := "../testdata/P_cat.csv"
filePath := "../testdata/P_resolve.csv"
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
if err != nil {
t.Error(err)
@ -414,19 +415,20 @@ func TestGetTXOToClaim(t *testing.T) {
// TestPrintClaimToTXO Utility function to cat the ClaimToTXO csv.
func TestPrintClaimToTXO(t *testing.T) {
filePath := "../testdata/E_2.csv"
filePath := "../testdata/E_resolve.csv"
CatCSV(filePath)
}
// TestGetClaimToTXO Tests getting a ClaimToTXO value from the db.
func TestGetClaimToTXO(t *testing.T) {
claimHashStr := "00000324e40fcb63a0b517a3660645e9bd99244a"
claimHashStr := "2556ed1cab9d17f2a9392030a9ad7f5d138f11bd"
want := uint32(0x6284e3)
claimHash, err := hex.DecodeString(claimHashStr)
if err != nil {
t.Error(err)
return
}
filePath := "../testdata/E_2.csv"
filePath := "../testdata/E_resolve.csv"
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
if err != nil {
t.Error(err)
@ -438,29 +440,38 @@ func TestGetClaimToTXO(t *testing.T) {
t.Error(err)
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.
func TestPrintClaimTakeover(t *testing.T) {
filePath := "../testdata/P_cat.csv"
filePath := "../testdata/P_resolve.csv"
CatCSV(filePath)
}
// TestGetControlingClaim Tests getting a controlling claim value from the db
// based on a name.
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)
if err != nil {
t.Error(err)
return
}
defer toDefer()
res, err := dbpkg.GetControllingClaim(db, "cat")
res, err := dbpkg.GetControllingClaim(db, claimName)
if err != nil {
t.Error(err)
return
}
got := hex.EncodeToString(res.ClaimHash)
if claimHash != got {
t.Errorf("Expected %s, got %s", claimHash, got)
}
log.Println(res)
}

13
main.go
View file

@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"log"
"os"
@ -110,10 +111,16 @@ func main() {
return
} else if args.CmdType == server.DBCmd3 {
// channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
var rawPrefix byte = prefixes.DBState
channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
// name := util.NormalizeName("@Styxhexenhammer666")
var rawPrefix byte = prefixes.ClaimToTXO
var startRaw []byte = nil
prefix := []byte{rawPrefix}
columnFamily := string(prefix)
// start := prefixes.NewClaimTakeoverKey(name)
start := prefixes.NewClaimToTXOKey(channelHash)
startRaw = start.PackKey()
// start := &prefixes.ChannelCountKey{
// Prefix: prefix,
// ChannelHash: channelHash,
@ -123,7 +130,7 @@ func main() {
options := &db.IterOptions{
FillCache: false,
Prefix: prefix,
Start: nil,
Start: startRaw,
Stop: nil,
IncludeStart: true,
IncludeStop: false,

11
testdata/E_2.csv vendored
View file

@ -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
1 E
2 E 45000000a420c44374f4f399ab4807fa1901eefc87 0297ec2100000297ec21000000000000000f42400100246167656e63652d64c3a974727569742c2d6e6f7576656175782d736b696e732d6c65616b
3 E 45000000c27eef5ea69e0d73f118826c7e326bb469 00371d66000000371d660000000000001dcd650001000e4d696e696174757265486f757365
4 E 4500000110e40894573f528c393fbcec7a472ec853 01516b32000001516b3200000000000000989680010021696f2d3137372d4e6f616d2d43686f6d736b792d6f6e2d434f494e54454c50524f
5 E 4500000324e40fcb63a0b517a3660645e9bd99244a 030bb6ba0000030bb6ba000000000000000f424001001b436f6e616e2d4578696c65732d526169642d4561726c792d457261
6 E 45000003d1538a0f19f5cd4bc1a62cc294f5c89934 011c7c990000011c7c99000000000000000f424001001130322d636172726167652d68616e646c65
7 E 45000008d47beeff8325e795a8604226145b01702b 02dbb2a2000002dbb2a2000000000000000186a001001039643336363661336161313231376138
8 E 4500000906499e073e94370ceff37cb21c28212444 0369842d00000369842d000000000000000186a001001033333465356465363139306534323466
9 E 45000009c3172e034a255f3c03566dca84bb9f046a 0225c69c000002251b0f0000000000000007a120010028617574686f722d73746f726965732d706f64636173742d657069736f64652d3734332d6b6172656e
10 E 45000009ca6e0caaaef16872b4bd4f6f1b8c2363e2 02b16956000002b16956000000000000000f4240010027554e2d504f55522d43454e542d28312d292d28536f72616c2c2d4162c3a963c3a9646169726529
11 E 4500000ad9ded2e15d18987900d09e9b29ef33d03e 02c972b3000002c972b3000000000000000186a0010006313331333333

2
testdata/E_resolve.csv vendored Normal file
View file

@ -0,0 +1,2 @@
E,,
E,452556ed1cab9d17f2a9392030a9ad7f5d138f11bd,006284e300000061ec7c0000000000000007a1200000134053747978686578656e68616d6d6572363636
1 E
2 E 452556ed1cab9d17f2a9392030a9ad7f5d138f11bd 006284e300000061ec7c0000000000000007a1200000134053747978686578656e68616d6d6572363636

11
testdata/P_cat.csv vendored
View file

@ -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
1 P
2 P 500003636174 7b07396275ce6b5fd30bfbc84f69dd7818c4e119000d695f
3 P 500003636176 6950f0e12745c690b28365738e0095c776d48dd2000d7fc0
4 P 50000363617a 9991c150e0e7df76163cbda34bd9bca59cc5a032000c2c3e
5 P 500003636231 3cd83b2b8e06867c3d8b066427896005881c5db9000bb158
6 P 500003636232 e7e1aa9d2e5d7c8e6349f06dfb0ff1fd8e69038f000fdd49
7 P 500003636233 d8d7099f4db8be475ed9e4ee2cd062fb6ce9533e000fc62b
8 P 500003636234 b696eb09a7529365015a033ebf4708101a1e1313000f17dd
9 P 500003636235 33b755873917f6c6d78a3777c3828827cc3a1e7e000fc68e
10 P 500003636236 ec06a840aaa04c2c09cc7f0b122ac3bbc2697e5b000fd4e8
11 P 500003636237 e1d0cdb9bd6f230f2d0eb860f1d634c737c52c95000f006d

2
testdata/P_resolve.csv vendored Normal file
View file

@ -0,0 +1,2 @@
P,,
P,5000134073747978686578656e68616d6d6572363636,2556ed1cab9d17f2a9392030a9ad7f5d138f11bd000a6471
1 P
2 P 5000134073747978686578656e68616d6d6572363636 2556ed1cab9d17f2a9392030a9ad7f5d138f11bd000a6471