diff --git a/packages/vm/core/evm/evmtest/evm_test.go b/packages/vm/core/evm/evmtest/evm_test.go index f352ff2ab5..d38538205c 100644 --- a/packages/vm/core/evm/evmtest/evm_test.go +++ b/packages/vm/core/evm/evmtest/evm_test.go @@ -817,6 +817,47 @@ func TestSendPayableValueTX(t *testing.T) { require.EqualValues(t, valueInBaseTokens, env.solo.L1BaseTokens(receiver)) } +func TestSendTimelock(t *testing.T) { + env := InitEVM(t, false) + + ethKey, senderEthAddress := env.Chain.NewEthereumAccountWithL2Funds() + _, receiver := env.solo.NewKeyPair() + + require.Zero(t, env.solo.L1BaseTokens(receiver)) + senderInitialBalance := env.Chain.L2BaseTokens(isc.NewEthereumAddressAgentID(env.Chain.ChainID, senderEthAddress)) + + value := util.BaseTokensDecimalsToEthereumDecimals(1*isc.Million, parameters.L1().BaseToken.Decimals) + + res, err := env.ISCMagicSandbox(ethKey).CallFn( + []ethCallOptions{{sender: ethKey, value: value, gasLimit: 100_000}}, + "send", iscmagic.WrapL1Address(receiver), + iscmagic.WrapISCAssets(isc.NewEmptyAssets()), + false, // auto adjust SD + iscmagic.ISCSendMetadata{}, + iscmagic.ISCSendOptions{ + Timelock: 1, + Expiration: iscmagic.ISCExpiration{ + Time: 0, + ReturnAddress: iscmagic.L1Address{}, + }, + }, + ) + require.NoError(t, err) + + decimals := parameters.L1().BaseToken.Decimals + valueInBaseTokens, bigRemainder := util.EthereumDecimalsToBaseTokenDecimals( + value, + decimals, + ) + require.Zero(t, bigRemainder.BitLen()) + + // L2 balance of sender is: initial - value sent in tx - gas fee + require.EqualValues(t, senderInitialBalance-valueInBaseTokens-res.ISCReceipt.GasFeeCharged, env.Chain.L2BaseTokens(isc.NewEthereumAddressAgentID(env.Chain.ChainID, senderEthAddress))) +} + +func TestFooBar(t *testing.T) { +} + func TestSendBaseTokens(t *testing.T) { env := InitEVM(t, true) diff --git a/packages/vm/core/evm/iscmagic/types.go b/packages/vm/core/evm/iscmagic/types.go index 77cc493af1..42d5195825 100644 --- a/packages/vm/core/evm/iscmagic/types.go +++ b/packages/vm/core/evm/iscmagic/types.go @@ -352,7 +352,7 @@ func (i *ISCExpiration) Unwrap() *isc.Expiration { ret := isc.Expiration{ ReturnAddress: address, - Time: time.UnixMilli(i.Time), + Time: time.Unix(i.Time, 0), } return &ret @@ -367,7 +367,7 @@ func (i *ISCSendOptions) Unwrap() isc.SendOptions { var timeLock time.Time if i.Timelock > 0 { - timeLock = time.UnixMilli(i.Timelock) + timeLock = time.Unix(i.Timelock, 0) } ret := isc.SendOptions{