Skip to content

Commit

Permalink
chore: Golang - unlike %#v, %+v doesn't print integers in hex
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed Jul 4, 2019
1 parent 428343e commit 11f8af3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions aeternity/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ func buildRLPMessage(tag uint, version uint, fields ...interface{}) (rlpRawMsg [
// create a message of the transaction and signature
data := []interface{}{tag, version}
data = append(data, fields...)
// fmt.Printf("TX %#v\n\n", data)
// fmt.Printf("TX %+v\n\n", data)
// encode the message using rlp
rlpRawMsg, err = rlp.EncodeToBytes(data)
// fmt.Printf("ENCODED %#v\n\n", data)
// fmt.Printf("ENCODED %+v\n\n", data)
return
}

Expand Down
24 changes: 12 additions & 12 deletions integration_test/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestAPI(t *testing.T) {
t.Logf("%+v\n", sentTxs)
t.Run("GetStatus", func(t *testing.T) {
gotStatus, err := privateNet.GetStatus()
// t.Logf("%#v\n", gotStatus)
// t.Logf("%+v\n", gotStatus)
if *gotStatus.NetworkID != "ae_docker" {
t.Errorf("Client.GetStatus(): Client testsuite should be run on private testnet (ae_docker), not %s", *gotStatus.NetworkID)
}
Expand All @@ -229,7 +229,7 @@ func TestAPI(t *testing.T) {
})
t.Run("GetTopBlock", func(t *testing.T) {
_, err := privateNet.GetTopBlock()
// t.Logf("%#v\n", gotTopBlock)
// t.Logf("%+v\n", gotTopBlock)
if err != nil {
t.Errorf("Client.GetTopBlock() error = %v", err)
return
Expand All @@ -248,7 +248,7 @@ func TestAPI(t *testing.T) {
})
t.Run("GetCurrentKeyBlock", func(t *testing.T) {
_, err := privateNet.GetCurrentKeyBlock()
// t.Logf("%#v\n", gotCurrentKeyBlock)
// t.Logf("%+v\n", gotCurrentKeyBlock)
if err != nil {
t.Errorf("Client.GetCurrentKeyBlock() error = %v", err)
return
Expand All @@ -258,7 +258,7 @@ func TestAPI(t *testing.T) {
t.Run("GetAccount", func(t *testing.T) {
var account = "ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi"
_, err := privateNet.GetAccount(account)
// t.Logf("%#v\n", gotAccount)
// t.Logf("%+v\n", gotAccount)
if err != nil {
t.Errorf("Client.GetAccount() error = %v", err)
return
Expand All @@ -271,7 +271,7 @@ func TestAPI(t *testing.T) {
t.Error(err)
}
_, err = privateNet.GetGenerationByHeight(height)
// t.Logf("%#v\n", gotGenerationByHeight)
// t.Logf("%+v\n", gotGenerationByHeight)
if err != nil {
t.Errorf("Client.GetGenerationByHeight() error = %v", err)
return
Expand All @@ -280,7 +280,7 @@ func TestAPI(t *testing.T) {

t.Run("GetMicroBlockHeaderByHash", func(t *testing.T) {
_, err := privateNet.GetMicroBlockHeaderByHash(sentTxs.SpendTx.mbHash)
// t.Logf("%#v\n", gotMicroBlockHeaderByHash)
// t.Logf("%+v\n", gotMicroBlockHeaderByHash)
if err != nil {
t.Errorf("Client.GetMicroBlockHeaderByHash() error = %v", err)
return
Expand All @@ -292,15 +292,15 @@ func TestAPI(t *testing.T) {
t.Skip("-testnet not specified: skipping test")
}
_, err := testNet.GetKeyBlockByHash("kh_2ZPK9GGvXKJ8vfwapBLztd2F8DSr9QdphZRHSdJH8MR298Guao")
// t.Logf("%#v\n", gotKeyBlockByHash)
// t.Logf("%+v\n", gotKeyBlockByHash)
if err != nil {
t.Errorf("Client.GetKeyBlockByHash() error = %v", err)
return
}
})
t.Run("GetMicroBlockTransactionsByHash", func(t *testing.T) {
_, err := privateNet.GetMicroBlockTransactionsByHash(sentTxs.SpendTx.mbHash)
// t.Logf("%#v\n", gotMicroBlockTransactionsByHash)
// t.Logf("%+v\n", gotMicroBlockTransactionsByHash)
if err != nil {
t.Errorf("Client.GetMicroBlockTransactionsByHash() error = %v", err)
return
Expand Down Expand Up @@ -431,31 +431,31 @@ func TestAPI(t *testing.T) {
})
t.Run("GetName", func(t *testing.T) {
_, err := privateNet.GetNameEntryByName(sentTxs.name)
// t.Logf("%#v\n", gotName)
// t.Logf("%+v\n", gotName)
if err != nil {
t.Errorf("Client.GetName() error = %v", err)
return
}
})
t.Run("GetOracleByPubkey", func(t *testing.T) {
_, err := privateNet.GetOracleByPubkey(sentTxs.oracleID)
// t.Logf("%#v\n", gotOracleByPubkey)
// t.Logf("%+v\n", gotOracleByPubkey)
if err != nil {
t.Errorf("Client.GetOracleByPubkey() error = %v", err)
return
}
})
t.Run("GetOracleQueriesByPubkey", func(t *testing.T) {
_, err := privateNet.GetOracleQueriesByPubkey(sentTxs.oracleID)
// t.Logf("%#v\n", gotOracleQueriesByPubkey)
// t.Logf("%+v\n", gotOracleQueriesByPubkey)
if err != nil {
t.Errorf("Client.GetOracleQueriesByPubkey() error = %v", err)
return
}
})
// t.Run("GetContractByID", func(t *testing.T) {
// _, err := privateNet.GetContractByID(sentTxs.contractID)
// // t.Logf("%#v\n", gotContractByID)
// // t.Logf("%+v\n", gotContractByID)
// if err != nil {
// t.Errorf("Client.GetContractByID() error = %v", err)
// return
Expand Down
4 changes: 2 additions & 2 deletions integration_test/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestContracts(t *testing.T) {
t.Fatal(err)
}
ctID, _ = create.ContractID()
fmt.Printf("Create %s, %#v\n", ctID, create)
fmt.Printf("Create %s, %+v\n", ctID, create)
txHash = signBroadcast(t, &create, alice, aeClient)
_, _, err = waitForTransaction(aeClient, txHash)
if err != nil {
Expand All @@ -45,7 +45,7 @@ func TestContracts(t *testing.T) {
if err != nil {
t.Fatal(err)
}
fmt.Printf("Call %#v\n", callTx)
fmt.Printf("Call %+v\n", callTx)
txHash = signBroadcast(t, &callTx, alice, aeClient)

_, _, err = waitForTransaction(aeClient, txHash)
Expand Down
4 changes: 2 additions & 2 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestBigIntLargerOrEqualToZero(t *testing.T) {
amountc := BigInt(*amount)
err := amountc.LargerOrEqualToZero()
if reflect.TypeOf(err) != reflect.TypeOf(test.expected) {
t.Errorf("Test Failed: %v inputted, %v expected, %#v received", test.input, test.expected, err)
t.Errorf("Test Failed: %v inputted, %v expected, %+v received", test.input, test.expected, err)
}
}
}
Expand All @@ -66,7 +66,7 @@ func TestBigIntLargerThanZero(t *testing.T) {
amountc := BigInt(*amount)
err := amountc.LargerThanZero()
if reflect.TypeOf(err) != reflect.TypeOf(test.expected) {
t.Errorf("Test Failed: %v inputted, %v expected, %#v received", test.input, test.expected, err)
t.Errorf("Test Failed: %v inputted, %v expected, %+v received", test.input, test.expected, err)
}
}
}
Expand Down

0 comments on commit 11f8af3

Please sign in to comment.