eth: add integration test

This commit is contained in:
jsvisa 2025-09-24 11:06:17 +08:00
parent a199748899
commit ea977525df

View file

@ -20,6 +20,7 @@ import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"errors" "errors"
"math"
"math/big" "math/big"
"testing" "testing"
"time" "time"
@ -130,6 +131,27 @@ func TestSendTx(t *testing.T) {
testSendTx(t, true) testSendTx(t, true)
} }
func TestSendTxEIP2681(t *testing.T) {
b := initBackend(false)
// Test EIP-2681: nonce overflow should be rejected
tx := makeTx(uint64(math.MaxUint64), nil, nil, key) // max uint64 nonce
err := b.SendTx(context.Background(), tx)
if err == nil {
t.Fatal("Expected EIP-2681 nonce overflow error, but transaction was accepted")
}
if !errors.Is(err, core.ErrNonceMax) {
t.Errorf("Expected core.ErrNonceMax, got: %v", err)
}
// Test normal case: should succeed
normalTx := makeTx(0, nil, nil, key)
err = b.SendTx(context.Background(), normalTx)
if err != nil {
t.Errorf("Normal transaction should succeed, got error: %v", err)
}
}
func testSendTx(t *testing.T, withLocal bool) { func testSendTx(t *testing.T, withLocal bool) {
b := initBackend(withLocal) b := initBackend(withLocal)