rocksdb #29

Merged
jeffreypicard merged 93 commits from feature/27/jeffreypicard/rocksdb into master 2022-04-29 17:04:01 +02:00
3 changed files with 41 additions and 6 deletions
Showing only changes of commit c73c078c26 - Show all commits

View file

@ -413,6 +413,38 @@ func TestGetTXOToClaim(t *testing.T) {
}
}
// TestPrintClaimToTXO Utility function to cat the ClaimToTXO csv.
func TestPrintSupportAmount(t *testing.T) {
filePath := "../testdata/a_resolve.csv"
CatCSV(filePath)
}
// TestGetClaimToTXO Tests getting a ClaimToTXO value from the db.
func TestGetSupportAmount(t *testing.T) {
claimHashStr := "2556ed1cab9d17f2a9392030a9ad7f5d138f11bd"
want := uint64(8654754160700)
claimHash, err := hex.DecodeString(claimHashStr)
if err != nil {
t.Error(err)
return
}
filePath := "../testdata/a_resolve.csv"
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
if err != nil {
t.Error(err)
return
}
defer toDefer()
res, err := dbpkg.GetSupportAmount(db, claimHash)
if err != nil {
t.Error(err)
return
}
if res != want {
t.Errorf("Expected %d, got %d", want, res)
}
}
func TestGetExpirationHeight(t *testing.T) {
var lastUpdated uint32 = 0
var expHeight uint32 = 0

13
main.go
View file

@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"log"
"os"
lyoshenka commented 2022-04-15 16:10:08 +02:00 (Migrated from github.com)
Review

prolly here just for profiling, right?

prolly here just for profiling, right?
jeffreypicard commented 2022-04-20 15:55:49 +02:00 (Migrated from github.com)
Review

yeah

yeah
@ -110,17 +111,17 @@ func main() {
return
} else if args.CmdType == server.DBCmd3 {
// channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
// name := util.NormalizeName("@Styxhexenhammer666")
txNum := uint32(0x6284e3)
position := uint16(0x0)
typ := uint8(prefixes.ACTIVATED_CLAIM_TXO_TYPE)
var rawPrefix byte = prefixes.ActivatedClaimAndSupport
// txNum := uint32(0x6284e3)
// position := uint16(0x0)
// typ := uint8(prefixes.ACTIVATED_CLAIM_TXO_TYPE)
var rawPrefix byte = prefixes.SupportAmount
var startRaw []byte = nil
prefix := []byte{rawPrefix}
columnFamily := string(prefix)
// start := prefixes.NewClaimTakeoverKey(name)
start := prefixes.NewActivationKey(typ, txNum, position)
start := prefixes.NewSupportAmountKey(channelHash)
startRaw = start.PackKey()
// start := &prefixes.ChannelCountKey{
// Prefix: prefix,

2
testdata/a_resolve.csv vendored Normal file
View file

@ -0,0 +1,2 @@
a,,
a,612556ed1cab9d17f2a9392030a9ad7f5d138f11bd,000007df178c203c
1 a
2 a 612556ed1cab9d17f2a9392030a9ad7f5d138f11bd 000007df178c203c