From 87e007d16cde2b3b0b10d7de70760425b39f768b Mon Sep 17 00:00:00 2001 From: kourin Date: Wed, 8 Jan 2025 23:59:02 +0900 Subject: [PATCH] Replace assert.NoError with require.NoError --- core/types/celo_transaction_marshalling_test.go | 11 ++++++----- core/types/celo_transaction_rlp_test.go | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/types/celo_transaction_marshalling_test.go b/core/types/celo_transaction_marshalling_test.go index b6b60b2bc0..16df52bc2e 100644 --- a/core/types/celo_transaction_marshalling_test.go +++ b/core/types/celo_transaction_marshalling_test.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // TestCeloTransactionMarshalUnmarshal tests that each Celo transactions marshal and unmarshal correctly @@ -300,10 +301,10 @@ func TestCeloTransactionMarshalUnmarshal(t *testing.T) { t.Helper() txJsonOuter, err := json.Marshal(tx) - assert.NoError(t, err) + require.NoError(t, err) txJsonInner, isCeloTx, err := celoTransactionMarshal(tx) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, isCeloTxType, isCeloTx) @@ -324,7 +325,7 @@ func TestCeloTransactionMarshalUnmarshal(t *testing.T) { tx := new(Transaction) err := json.Unmarshal([]byte(jsonData), tx) - assert.NoError(t, err) + require.NoError(t, err) // Reassign the signature values because *hexutil.Big decodes "0x0" as nil for the `abs` field. // This causes a mismatch with `big.NewInt(0)` @@ -347,12 +348,12 @@ func TestCeloTransactionMarshalUnmarshal(t *testing.T) { // Create a copy of the JSON data and remove one of the required fields var jsonMap map[string]interface{} err := json.Unmarshal([]byte(jsonData), &jsonMap) - assert.NoError(t, err) + require.NoError(t, err) delete(jsonMap, field) newJsonData, err := json.Marshal(jsonMap) - assert.NoError(t, err) + require.NoError(t, err) // Attempt to unmarshal the JSON data tx := new(Transaction) diff --git a/core/types/celo_transaction_rlp_test.go b/core/types/celo_transaction_rlp_test.go index 82dc5a5eb8..8aafb863a5 100644 --- a/core/types/celo_transaction_rlp_test.go +++ b/core/types/celo_transaction_rlp_test.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // TestCeloTransactionRLPEncodingDecoding tests the RLP encoding and decoding of Celo transactions @@ -57,7 +58,7 @@ func TestCeloTransactionRLPEncodingDecoding(t *testing.T) { t.Helper() data, err := rlp.EncodeToBytes(value) - assert.NoError(t, err) + require.NoError(t, err) return data } @@ -264,7 +265,7 @@ func TestCeloTransactionRLPEncodingDecoding(t *testing.T) { var buf bytes.Buffer err := tx.EncodeRLP(&buf) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedByte, buf.Bytes()) } @@ -273,8 +274,8 @@ func TestCeloTransactionRLPEncodingDecoding(t *testing.T) { t.Helper() data, err := tx.MarshalBinary() + require.NoError(t, err) - assert.NoError(t, err) assert.Equal(t, expectedByte, data) } @@ -283,8 +284,8 @@ func TestCeloTransactionRLPEncodingDecoding(t *testing.T) { tx := new(Transaction) err := rlp.DecodeBytes(bytes, tx) + require.NoError(t, err) - assert.NoError(t, err) assert.Equal(t, expectedTx.inner, tx.inner) } @@ -293,8 +294,8 @@ func TestCeloTransactionRLPEncodingDecoding(t *testing.T) { tx := new(Transaction) err := tx.UnmarshalBinary(bytes) + require.NoError(t, err) - assert.NoError(t, err) assert.Equal(t, expectedTx.inner, tx.inner) }