small refactor

This commit is contained in:
Alex Grintsvayg 2018-10-25 14:20:44 -04:00
parent 92e35bd23a
commit dd284f117f
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5
3 changed files with 15 additions and 18 deletions

View file

@ -1,4 +1,4 @@
package util package lbrycrd
import ( import (
"crypto/sha256" "crypto/sha256"

View file

@ -1,17 +1,16 @@
package util package lbrycrd_test
import ( import (
"testing" "testing"
"github.com/lbryio/lbry.go/lbrycrd"
) )
type claimIdMatch struct { var claimIdTests = []struct {
ClaimId string claimID string
TxHash string txHash string
N uint n int
} }{
var claimIdTests = []claimIdMatch{
{"589bc4845caca70977332025990b2a1807732b44", {"589bc4845caca70977332025990b2a1807732b44",
"6a9dbe3084b86cec8aa519970d2245dfa15193294cab65819a0d96d455c2a5df", "6a9dbe3084b86cec8aa519970d2245dfa15193294cab65819a0d96d455c2a5df",
1}, 1},
@ -43,15 +42,13 @@ var claimIdTests = []claimIdMatch{
} }
func TestGetClaimIDFromOutput(t *testing.T) { func TestGetClaimIDFromOutput(t *testing.T) {
for _, test := range claimIdTests {
for _, claimMatch := range claimIdTests { claimID, err := lbrycrd.ClaimIDFromOutpoint(test.txHash, test.n)
claimID, err := ClaimIDFromOutpoint(claimMatch.TxHash, int(claimMatch.N))
if err != nil { if err != nil {
t.Error(err) t.Errorf("%s: %v", test.claimID, err)
} }
if claimID != claimMatch.ClaimId { if test.claimID != claimID {
t.Error("Expected ", claimMatch.ClaimId, " got ", claimID) t.Errorf("expected %s, got %s", test.claimID, claimID)
} }
} }
} }

View file

@ -1,4 +1,4 @@
package querytools package query
import ( import (
"bytes" "bytes"