added time-range tests

This commit is contained in:
Dror Tirosh 2024-07-01 14:23:48 +03:00
parent 702d157aef
commit 49bc2a8570
2 changed files with 19 additions and 0 deletions

View file

@ -46,6 +46,7 @@ func newTestContextBuilder(t *testing.T) *testContextBuilder {
func (tb *testContextBuilder) build() *testContext { func (tb *testContextBuilder) build() *testContext {
genesis := core.DeveloperGenesisBlock(10_000_000, &common.Address{}) genesis := core.DeveloperGenesisBlock(10_000_000, &common.Address{})
genesis.Timestamp = 100
genesisBlock := genesis.ToBlock() genesisBlock := genesis.ToBlock()
gaspool := new(core.GasPool).AddGas(genesisBlock.GasLimit()) gaspool := new(core.GasPool).AddGas(genesisBlock.GasLimit())

View file

@ -51,6 +51,24 @@ func TestValidationFailure_sigerror(t *testing.T) {
}, "account signature error") }, "account signature error")
} }
func TestValidationFailure_validAfter(t *testing.T) {
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
returnData(core.PackValidationData(core.MAGIC_VALUE_SENDER, 300, 200)), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
ValidationGas: uint64(1000000000),
GasFeeCap: big.NewInt(1000000000),
}, "RIP-7560 transaction validity not reached yet")
}
func TestValidationFailure_validUntil(t *testing.T) {
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
returnData(core.PackValidationData(core.MAGIC_VALUE_SENDER, 1, 0)), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
ValidationGas: uint64(1000000000),
GasFeeCap: big.NewInt(1000000000),
}, "RIP-7560 transaction validity expired")
}
func TestValidation_ok(t *testing.T) { func TestValidation_ok(t *testing.T) {
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{ handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{