From dd284f117f981ab139f09dce04559103cd41d246 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Thu, 25 Oct 2018 14:20:44 -0400 Subject: [PATCH] small refactor --- {util => lbrycrd}/blockchain.go | 2 +- {util => lbrycrd}/blockchain_test.go | 29 +++++++++++++--------------- {querytools => query}/query.go | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) rename {util => lbrycrd}/blockchain.go (98%) rename {util => lbrycrd}/blockchain_test.go (74%) rename {querytools => query}/query.go (99%) diff --git a/util/blockchain.go b/lbrycrd/blockchain.go similarity index 98% rename from util/blockchain.go rename to lbrycrd/blockchain.go index b134e68..dc88cc5 100644 --- a/util/blockchain.go +++ b/lbrycrd/blockchain.go @@ -1,4 +1,4 @@ -package util +package lbrycrd import ( "crypto/sha256" diff --git a/util/blockchain_test.go b/lbrycrd/blockchain_test.go similarity index 74% rename from util/blockchain_test.go rename to lbrycrd/blockchain_test.go index 5ca164c..b9986f6 100644 --- a/util/blockchain_test.go +++ b/lbrycrd/blockchain_test.go @@ -1,17 +1,16 @@ -package util +package lbrycrd_test import ( "testing" + + "github.com/lbryio/lbry.go/lbrycrd" ) -type claimIdMatch struct { - ClaimId string - TxHash string - N uint -} - -var claimIdTests = []claimIdMatch{ - +var claimIdTests = []struct { + claimID string + txHash string + n int +}{ {"589bc4845caca70977332025990b2a1807732b44", "6a9dbe3084b86cec8aa519970d2245dfa15193294cab65819a0d96d455c2a5df", 1}, @@ -43,15 +42,13 @@ var claimIdTests = []claimIdMatch{ } func TestGetClaimIDFromOutput(t *testing.T) { - - for _, claimMatch := range claimIdTests { - claimID, err := ClaimIDFromOutpoint(claimMatch.TxHash, int(claimMatch.N)) + for _, test := range claimIdTests { + claimID, err := lbrycrd.ClaimIDFromOutpoint(test.txHash, test.n) if err != nil { - t.Error(err) + t.Errorf("%s: %v", test.claimID, err) } - if claimID != claimMatch.ClaimId { - t.Error("Expected ", claimMatch.ClaimId, " got ", claimID) + if test.claimID != claimID { + t.Errorf("expected %s, got %s", test.claimID, claimID) } } - } diff --git a/querytools/query.go b/query/query.go similarity index 99% rename from querytools/query.go rename to query/query.go index 1a8cbc7..7edbdbb 100644 --- a/querytools/query.go +++ b/query/query.go @@ -1,4 +1,4 @@ -package querytools +package query import ( "bytes"