mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
ethclient/simulated: include type 0x03 and 0x04 transactions to testing
This commit is contained in:
parent
2ca14aa5f0
commit
975d4f8b70
1 changed files with 24 additions and 16 deletions
|
|
@ -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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue