Skip to content

Commit

Permalink
run tests in branch
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Nov 16, 2023
1 parent 65bd1e8 commit efa8c8e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
21 changes: 11 additions & 10 deletions test/arc_txt_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
}
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions test/callback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/double_spend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 11 additions & 12 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit efa8c8e

Please sign in to comment.