Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Add TestOverrideAccount_ToType
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Oct 23, 2023
1 parent 864f36d commit 7598819
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions jsonrpc/eth_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/0xPolygon/polygon-edge/types"
"github.com/hashicorp/go-hclog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestEth_DecodeTxn(t *testing.T) {
Expand Down Expand Up @@ -364,3 +365,29 @@ func TestEth_HeaderResolveBlock(t *testing.T) {
}
}
}

func TestOverrideAccount_ToType(t *testing.T) {
t.Parallel()

nonce := uint64(10)
code := []byte("SC code")
balance := uint64(10000)
state := map[types.Hash]types.Hash{types.StringToHash("1"): types.StringToHash("2")}
stateDiff := map[types.Hash]types.Hash{types.StringToHash("3"): types.StringToHash("4")}

overrideAcc := &overrideAccount{
Nonce: toArgUint64Ptr(nonce),
Code: toArgBytesPtr(code),
Balance: toArgUint64Ptr(balance),
State: &state,
StateDiff: &stateDiff,
}

convertedAcc := overrideAcc.ToType()
require.NotNil(t, convertedAcc)
require.Equal(t, nonce, *convertedAcc.Nonce)
require.Equal(t, code, convertedAcc.Code)
require.Equal(t, new(big.Int).SetUint64(balance), convertedAcc.Balance)
require.Equal(t, state, convertedAcc.State)
require.Equal(t, stateDiff, convertedAcc.StateDiff)
}

0 comments on commit 7598819

Please sign in to comment.