diff --git a/test/arc_txt_endpoint_test.go b/test/arc_txt_endpoint_test.go index 46438e781..4eb8b9aa0 100644 --- a/test/arc_txt_endpoint_test.go +++ b/test/arc_txt_endpoint_test.go @@ -41,10 +41,10 @@ type TxStatusResponse struct { Txid string `json:"txid"` } -var ( - address string - privateKey string -) +//var ( +// address string +// privateKey string +//) func TestMain(m *testing.M) { info, err := bitcoind.GetInfo() @@ -54,12 +54,12 @@ func TestMain(m *testing.M) { log.Printf("current block height: %d", info.Blocks) - address, privateKey, err := getNewWalletAddress() - if err != nil { - log.Fatalf("failed to get new wallet address: %v", err) - } - log.Println(fmt.Sprintf("new address: %s", address)) - log.Println(fmt.Sprintf("new private key: %s", privateKey)) + //address, privateKey, err := getNewWalletAddress() + //if err != nil { + // log.Fatalf("failed to get new wallet address: %v", err) + //} + //log.Println(fmt.Sprintf("new address: %s", address)) + //log.Println(fmt.Sprintf("new private key: %s", privateKey)) os.Exit(m.Run()) } @@ -113,6 +113,7 @@ func createTx(privateKey string, address string, utxo NodeUnspentUtxo) (*bt.Tx, } func TestHttpPost(t *testing.T) { + address, privateKey := getNewWalletAddress(t) generate(t, 100) diff --git a/test/callback_test.go b/test/callback_test.go index c4153752c..ca18051a9 100644 --- a/test/callback_test.go +++ b/test/callback_test.go @@ -28,6 +28,8 @@ func TestPostCallbackToken(t *testing.T) { for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { + address, privateKey := getNewWalletAddress(t) + generate(t, 100) t.Logf("generated address: %s", address) diff --git a/test/double_spend_test.go b/test/double_spend_test.go index ec929f5c5..1cd9c2c8e 100644 --- a/test/double_spend_test.go +++ b/test/double_spend_test.go @@ -28,6 +28,8 @@ func TestDoubleSpend(t *testing.T) { for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { + address, privateKey := getNewWalletAddress(t) + generate(t, 100) t.Logf("generated address: %s", address) diff --git a/test/utils.go b/test/utils.go index fafefd3d8..9467e2761 100644 --- a/test/utils.go +++ b/test/utils.go @@ -62,21 +62,20 @@ func init() { } -func getNewWalletAddress() (address, privateKey string, err error) { - address, err = bitcoind.GetNewAddress() - if err != nil { - return - } +func getNewWalletAddress(t *testing.T) (address, privateKey string) { + address, err := bitcoind.GetNewAddress() + require.NoError(t, err) + t.Logf("new address: %s", address) privateKey, err = bitcoind.DumpPrivKey(address) - if err != nil { - return - } + require.NoError(t, err) + t.Logf("new private key: %s", privateKey) - err = bitcoind.SetAccount(address, "test-account") - if err != nil { - return - } + accountName := "test-account" + err = bitcoind.SetAccount(address, accountName) + require.NoError(t, err) + + t.Logf("account %s created", accountName) return }