ethclient/simulated: include type 0x03 and 0x04 transactions to testing

This commit is contained in:
tr1sm0s1n 2025-03-02 00:15:19 +05:30
parent 2ca14aa5f0
commit 975d4f8b70
No known key found for this signature in database
GPG key ID: 0F30FF07CAB2F87A

View file

@ -195,30 +195,38 @@ func TestAdjustTime(t *testing.T) {
} }
} }
func TestSendTransaction(t *testing.T) { func TestSendTransactions(t *testing.T) {
sim := simTestBackend(testAddr) sim := simTestBackend(testAddr)
defer sim.Close() defer sim.Close()
client := sim.Client() client := sim.Client()
ctx := context.Background() ctx := context.Background()
signedTx, err := newTx(sim, testKey) txs := []func(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error){
if err != nil { newTx,
t.Errorf("could not create transaction: %v", err) newBlobTx,
} newSetCodeTx,
// send tx to simulated backend
err = client.SendTransaction(ctx, signedTx)
if err != nil {
t.Errorf("could not add tx to pending block: %v", err)
}
sim.Commit()
block, err := client.BlockByNumber(ctx, big.NewInt(1))
if err != nil {
t.Errorf("could not get block at height 1: %v", err)
} }
if signedTx.Hash() != block.Transactions()[0].Hash() { for _, tx := range txs {
t.Errorf("did not commit sent transaction. expected hash %v got hash %v", block.Transactions()[0].Hash(), signedTx.Hash()) signedTx, err := tx(sim, testKey)
if err != nil {
t.Errorf("could not create transaction: %v", err)
}
// send tx to simulated backend
err = client.SendTransaction(ctx, signedTx)
if err != nil {
t.Errorf("could not add tx to pending block: %v", err)
}
sim.Commit()
block, err := client.BlockByNumber(ctx, nil)
if err != nil {
t.Errorf("could not get block at height 1: %v", err)
}
if signedTx.Hash() != block.Transactions()[0].Hash() {
t.Errorf("did not commit sent transaction. expected hash %v got hash %v", block.Transactions()[0].Hash(), signedTx.Hash())
}
} }
} }