extend test

This commit is contained in:
Sina Mahmoodi 2025-05-02 16:30:48 +02:00
parent bce6847c51
commit d7683b3ef4

View file

@ -2406,11 +2406,15 @@ func TestSimulateV1ChainLinkage(t *testing.T) {
func TestSimulateV1TxSender(t *testing.T) {
var (
sender = common.Address{0xaa, 0xaa}
sender2 = common.Address{0xaa, 0xab}
sender3 = common.Address{0xaa, 0xac}
recipient = common.Address{0xbb, 0xbb}
gspec = &core.Genesis{
Config: params.MergedTestChainConfig,
Alloc: types.GenesisAlloc{
sender: {Balance: big.NewInt(params.Ether)},
sender: {Balance: big.NewInt(params.Ether)},
sender2: {Balance: big.NewInt(params.Ether)},
sender3: {Balance: big.NewInt(params.Ether)},
},
}
ctx = context.Background()
@ -2435,13 +2439,19 @@ func TestSimulateV1TxSender(t *testing.T) {
results, err := sim.execute(ctx, []simBlock{
{Calls: []TransactionArgs{
{From: &sender, To: &recipient, Value: (*hexutil.Big)(big.NewInt(1000))},
{From: &sender2, To: &recipient, Value: (*hexutil.Big)(big.NewInt(2000))},
{From: &sender3, To: &recipient, Value: (*hexutil.Big)(big.NewInt(3000))},
}},
{Calls: []TransactionArgs{
{From: &sender2, To: &recipient, Value: (*hexutil.Big)(big.NewInt(4000))},
}},
})
if err != nil {
t.Fatalf("simulation execution failed: %v", err)
}
require.Len(t, results, 1, "expected 1 simulated blocks")
require.Len(t, results[0].Block.Transactions(), 1, "expected 1 transaction in simulated block")
require.Len(t, results, 2, "expected 2 simulated blocks")
require.Len(t, results[0].Block.Transactions(), 3, "expected 3 transaction in simulated block")
require.Len(t, results[1].Block.Transactions(), 1, "expected 1 transaction in 2nd simulated block")
enc, err := json.Marshal(results)
if err != nil {
t.Fatalf("failed to marshal results: %v", err)
@ -2455,9 +2465,13 @@ func TestSimulateV1TxSender(t *testing.T) {
if err := json.Unmarshal(enc, &summary); err != nil {
t.Fatalf("failed to unmarshal results: %v", err)
}
require.Len(t, summary, 1, "expected 1 transaction in simulated block")
require.Len(t, summary[0].Transactions, 1, "expected 1 transaction in simulated block")
require.Len(t, summary, 2, "expected 2 simulated blocks")
require.Len(t, summary[0].Transactions, 3, "expected 3 transaction in simulated block")
require.Equal(t, sender, summary[0].Transactions[0].From, "sender address mismatch")
require.Equal(t, sender2, summary[0].Transactions[1].From, "sender address mismatch")
require.Equal(t, sender3, summary[0].Transactions[2].From, "sender address mismatch")
require.Len(t, summary[1].Transactions, 1, "expected 1 transaction in simulated block")
require.Equal(t, sender2, summary[1].Transactions[0].From, "sender address mismatch")
}
func TestSignTransaction(t *testing.T) {