mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
Extend ethclient test, implement new TxID spec
- Implement new TxID spec that distinguishes L1UserTx and L1CoordinatorTx - Replace some type []*Foo by []Foo - Fix HistoryDB & L2DB bug: in case of error, a rollback was applied and the returned error was nil - Reorder inserts in historydb.NewHistoryDB() to follow foreign key dependencies - Add initial synchronizer test with test.Client (for now, only tested l1UserTxs, blocks, addToken) - Update L1UserTx event in test.Client
This commit is contained in:
@@ -15,23 +15,40 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewL1Tx(t *testing.T) {
|
||||
toForge := new(int64)
|
||||
*toForge = 123456
|
||||
fromIdx := new(Idx)
|
||||
*fromIdx = 300
|
||||
func TestNewL1UserTx(t *testing.T) {
|
||||
toForge := int64(123456)
|
||||
fromIdx := Idx(300)
|
||||
l1Tx := &L1Tx{
|
||||
ToForgeL1TxsNum: toForge,
|
||||
ToForgeL1TxsNum: &toForge,
|
||||
Position: 71,
|
||||
UserOrigin: true,
|
||||
ToIdx: 301,
|
||||
TokenID: 5,
|
||||
Amount: big.NewInt(1),
|
||||
LoadAmount: big.NewInt(2),
|
||||
FromIdx: fromIdx,
|
||||
FromIdx: &fromIdx,
|
||||
}
|
||||
l1Tx, err := NewL1Tx(l1Tx)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "0x01000000000001e240004700", l1Tx.TxID.String())
|
||||
assert.Equal(t, "0x00000000000001e240004700", l1Tx.TxID.String())
|
||||
}
|
||||
|
||||
func TestNewL1CoordinatorTx(t *testing.T) {
|
||||
fromIdx := Idx(300)
|
||||
batchNum := BatchNum(51966)
|
||||
l1Tx := &L1Tx{
|
||||
Position: 88,
|
||||
UserOrigin: false,
|
||||
ToIdx: 301,
|
||||
TokenID: 5,
|
||||
Amount: big.NewInt(1),
|
||||
LoadAmount: big.NewInt(2),
|
||||
FromIdx: &fromIdx,
|
||||
BatchNum: &batchNum,
|
||||
}
|
||||
l1Tx, err := NewL1Tx(l1Tx)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "0x01000000000000cafe005800", l1Tx.TxID.String())
|
||||
}
|
||||
|
||||
func TestL1TxByteParsers(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user