Skip to content

Commit

Permalink
Replace assert.NoError with require.NoError
Browse files Browse the repository at this point in the history
  • Loading branch information
Kourin1996 committed Jan 8, 2025
1 parent 15f2f68 commit 87e007d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions core/types/celo_transaction_marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)`
Expand All @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions core/types/celo_transaction_rlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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())
}
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit 87e007d

Please sign in to comment.