Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Dec 21, 2023
1 parent fe72cbe commit b916284
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
15 changes: 5 additions & 10 deletions bump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func TestNewBUMPFromMerkleTreeWithOnlyOneTxid(t *testing.T) {
hash, err := chainhash.NewHashFromStr(txidSmallBlock)
require.NoError(t, err)
chainHashBlock = append(chainHashBlock, hash)
merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock)
require.NoError(t, err)
merkles := BuildMerkleTreeStoreChainHash(chainHashBlock)
bump, err := NewBUMPFromMerkleTreeAndIndex(fakeMadeUpNum, merkles, uint64(0))
require.NoError(t, err)
root, err := bump.CalculateRootGivenTxid(txidSmallBlock)
Expand All @@ -66,8 +65,7 @@ func TestNewBUMPFromMerkleTree(t *testing.T) {
require.NoError(t, err)
chainHashBlock = append(chainHashBlock, hash)
}
merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock)
require.NoError(t, err)
merkles := BuildMerkleTreeStoreChainHash(chainHashBlock)
for txIndex, txid := range blockTxExample {
bump, err := NewBUMPFromMerkleTreeAndIndex(fakeMadeUpNum, merkles, uint64(txIndex))
require.NoError(t, err)
Expand Down Expand Up @@ -108,8 +106,7 @@ func TestTestnetCalculateRootGivenTxid(t *testing.T) {
require.NoError(t, err)
chainHashBlock = append(chainHashBlock, hash)
}
merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock)
require.NoError(t, err)
merkles := BuildMerkleTreeStoreChainHash(chainHashBlock)
for txIndex, txid := range testnetBlockExample {
bump, err := NewBUMPFromMerkleTreeAndIndex(1575794, merkles, uint64(txIndex))
require.NoError(t, err)
Expand Down Expand Up @@ -161,8 +158,7 @@ func TestTxids(t *testing.T) {
require.NoError(t, err)
chainHashBlock = append(chainHashBlock, hash)
}
merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock)
require.NoError(t, err)
merkles := BuildMerkleTreeStoreChainHash(chainHashBlock)

bump, err := NewBUMPFromMerkleTreeAndIndex(1575794, merkles, uint64(0))
require.NoError(t, err)
Expand All @@ -177,8 +173,7 @@ func TestOnlySpecifiedPathsStored(t *testing.T) {
require.NoError(t, err)
chainHashBlock = append(chainHashBlock, hash)
}
merkles, err := BuildMerkleTreeStoreChainHash(chainHashBlock)
require.NoError(t, err)
merkles := BuildMerkleTreeStoreChainHash(chainHashBlock)

for idx := range blockTxExample {
bump, err := NewBUMPFromMerkleTreeAndIndex(1575794, merkles, uint64(idx))
Expand Down
6 changes: 2 additions & 4 deletions merkleroot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func TestBuildMerkleTreeStoreChainHash(t *testing.T) {
transactionHashes[i], _ = chainhash.NewHashFromStr(txid)
}

merkleTreeChainStore, err := bc.BuildMerkleTreeStoreChainHash(transactionHashes)
require.NoError(t, err)
merkleTreeChainStore := bc.BuildMerkleTreeStoreChainHash(transactionHashes)

actual := merkleTreeChainStore[len(merkleTreeChainStore)-1].String()

Expand Down Expand Up @@ -114,8 +113,7 @@ func TestBuildMerkleTreeStoreChainHashDifferentSizes(t *testing.T) {
transactionHashes[idx] = h
}

merkleTreeChainStore, err := bc.BuildMerkleTreeStoreChainHash(transactionHashes)
require.NoError(t, err)
merkleTreeChainStore := bc.BuildMerkleTreeStoreChainHash(transactionHashes)

actual := merkleTreeChainStore[len(merkleTreeChainStore)-1].String()

Expand Down

0 comments on commit b916284

Please sign in to comment.