Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use unix seconds intead of milliseconds #3498

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/vm/core/evm/evmtest/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

jorgemmsilva marked this conversation as resolved.
Show resolved Hide resolved
func TestSendBaseTokens(t *testing.T) {
env := InitEVM(t, true)

Expand Down
4 changes: 2 additions & 2 deletions packages/vm/core/evm/iscmagic/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand Down
Loading