From 9dcf166080dc69dee4ec0029235e44de4190793c Mon Sep 17 00:00:00 2001 From: arnaucube Date: Tue, 23 Feb 2021 16:27:05 +0100 Subject: [PATCH] Extend L1Tx TxID tests for js checks --- common/l1tx_test.go | 34 +++++++++++++++++++++++++++++++++- common/l2tx_test.go | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/common/l1tx_test.go b/common/l1tx_test.go index effb51c..9a5ad92 100644 --- a/common/l1tx_test.go +++ b/common/l1tx_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestNewL1UserTx(t *testing.T) { +func TestNewL1UserTxID(t *testing.T) { toForge := int64(123456) l1Tx := &L1Tx{ ToForgeL1TxsNum: &toForge, @@ -30,6 +30,38 @@ func TestNewL1UserTx(t *testing.T) { l1Tx, err := NewL1Tx(l1Tx) assert.NoError(t, err) assert.Equal(t, "0x00a6cbae3b8661fb75b0919ca6605a02cfb04d9c6dd16870fa0fcdf01befa32768", l1Tx.TxID.String()) + + maxInt64 := 0xFFFF_FFFF_FFFF_FFFF >> 1 + + toForge = int64(maxInt64) + l1Tx = &L1Tx{ + ToForgeL1TxsNum: &toForge, + Position: maxInt64, + UserOrigin: true, + } + l1Tx, err = NewL1Tx(l1Tx) + assert.NoError(t, err) + assert.Equal(t, "0x001ff31eb325f324652bfe6b607a19e04789e082ee3b779eefe4a466062ea331d9", l1Tx.TxID.String()) + + toForge = int64(maxInt64 - 1) + l1Tx = &L1Tx{ + ToForgeL1TxsNum: &toForge, + Position: maxInt64 - 1, + UserOrigin: true, + } + l1Tx, err = NewL1Tx(l1Tx) + assert.NoError(t, err) + assert.Equal(t, "0x0003434eca58d35fd85795e3a6cce67c8801deb805ea1f7429cc270aa9f35ea403", l1Tx.TxID.String()) + + toForge = int64(0) + l1Tx = &L1Tx{ + ToForgeL1TxsNum: &toForge, + Position: 0, + UserOrigin: true, + } + l1Tx, err = NewL1Tx(l1Tx) + assert.NoError(t, err) + assert.Equal(t, "0x006bd2dd6bd408cbee33429358bf24fdc64612fbf8b1b4db604518f40ffd34b607", l1Tx.TxID.String()) } func TestNewL1CoordinatorTx(t *testing.T) { diff --git a/common/l2tx_test.go b/common/l2tx_test.go index f5b7d8e..bf97c1c 100644 --- a/common/l2tx_test.go +++ b/common/l2tx_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestNewL2Tx(t *testing.T) { +func TestNewL2TxID(t *testing.T) { l2Tx := &L2Tx{ FromIdx: 87654, ToIdx: 300,