mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
paymaster time-range checking
This commit is contained in:
parent
b0b490f350
commit
603d385c05
2 changed files with 21 additions and 1 deletions
|
|
@ -486,7 +486,7 @@ func validatePaymasterReturnData(data []byte) (context []byte, validAfter, valid
|
|||
if validationData == nil {
|
||||
return nil, 0, 0, errors.New("invalid paymaster return data")
|
||||
}
|
||||
magicExpected, validAfter, validUntil := UnpackValidationData(validationData)
|
||||
magicExpected, validUntil, validAfter := UnpackValidationData(validationData)
|
||||
if magicExpected != MAGIC_VALUE_PAYMASTER {
|
||||
return nil, 0, 0, errors.New("paymaster did not return correct MAGIC_VALUE")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,26 @@ func TestPaymasterValidationFailure_contextTooLarge(t *testing.T) {
|
|||
}, "paymaster context too large")
|
||||
}
|
||||
|
||||
func TestPaymasterValidationFailure_validAfter(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(core.MAGIC_VALUE_PAYMASTER, 300, 200, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "RIP-7560 transaction validity not reached yet")
|
||||
}
|
||||
|
||||
func TestPaymasterValidationFailure_validUntil(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(core.MAGIC_VALUE_PAYMASTER, 1, 0, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "RIP-7560 transaction validity expired")
|
||||
}
|
||||
|
||||
func TestPaymasterValidation_ok(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(core.MAGIC_VALUE_PAYMASTER, 0, 0, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
|
|
|
|||
Loading…
Reference in a new issue