From 49bc2a85701ec4c4beab2abae3129e00c12c0f16 Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Mon, 1 Jul 2024 14:23:48 +0300 Subject: [PATCH] added time-range tests --- tests/rip7560/rip7560TestUtils.go | 1 + tests/rip7560/validation_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/rip7560/rip7560TestUtils.go b/tests/rip7560/rip7560TestUtils.go index 710fc51897..1e50d9b7fb 100644 --- a/tests/rip7560/rip7560TestUtils.go +++ b/tests/rip7560/rip7560TestUtils.go @@ -46,6 +46,7 @@ func newTestContextBuilder(t *testing.T) *testContextBuilder { func (tb *testContextBuilder) build() *testContext { genesis := core.DeveloperGenesisBlock(10_000_000, &common.Address{}) + genesis.Timestamp = 100 genesisBlock := genesis.ToBlock() gaspool := new(core.GasPool).AddGas(genesisBlock.GasLimit()) diff --git a/tests/rip7560/validation_test.go b/tests/rip7560/validation_test.go index cd44610b1c..7ab87ddee5 100644 --- a/tests/rip7560/validation_test.go +++ b/tests/rip7560/validation_test.go @@ -51,6 +51,24 @@ func TestValidationFailure_sigerror(t *testing.T) { }, "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) { handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{