mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Add ProcessTxs send fees to Coordinator accounts
This commit is contained in:
@@ -32,7 +32,7 @@ CreateAccountDepositTransfer(1) B-A: 40, 10
|
||||
|
||||
// transaction generated by the Coordinator, create account for user User0 for
|
||||
// the TokenID=2, with a deposit of 0
|
||||
CreateAccountDepositCoordinator(2) User0
|
||||
CreateAccountCoordinator(2) User0
|
||||
|
||||
|
||||
// deposit of TokenID=1, at the account A, of 6 units
|
||||
|
||||
@@ -350,7 +350,7 @@ func (p *parser) parseLine(setType setType) (*instruction, error) {
|
||||
case "CreateAccountDepositTransfer":
|
||||
c.typ = common.TxTypeCreateAccountDepositTransfer
|
||||
transferring = true
|
||||
case "CreateAccountDepositCoordinator":
|
||||
case "CreateAccountCoordinator":
|
||||
c.typ = txTypeCreateAccountDepositCoordinator
|
||||
// transferring is false, as the Coordinator tx transfer will be 0
|
||||
case "DepositTransfer":
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestParseBlockchainTxs(t *testing.T) {
|
||||
Deposit(1) B: 5
|
||||
CreateAccountDeposit(1) C: 5
|
||||
CreateAccountDepositTransfer(1) D-A: 15, 10
|
||||
CreateAccountDepositCoordinator(1) E
|
||||
CreateAccountCoordinator(1) E
|
||||
|
||||
// L2 transactions
|
||||
Transfer(1) A-B: 6 (1)
|
||||
|
||||
@@ -10,6 +10,14 @@ AddToken(1)
|
||||
AddToken(2)
|
||||
AddToken(3)
|
||||
|
||||
// Coordinator accounts, Idxs: 256, 257, 258, 259
|
||||
CreateAccountCoordinator(0) Coord
|
||||
CreateAccountCoordinator(1) Coord
|
||||
CreateAccountCoordinator(2) Coord
|
||||
CreateAccountCoordinator(3) Coord
|
||||
|
||||
> batch
|
||||
|
||||
// deposits TokenID: 1
|
||||
CreateAccountDeposit(1) A: 50
|
||||
CreateAccountDeposit(1) B: 5
|
||||
@@ -42,6 +50,9 @@ CreateAccountDeposit(2) B: 5
|
||||
CreateAccountDeposit(2) A: 20
|
||||
// deposits TokenID: 3
|
||||
CreateAccountDeposit(3) B: 100
|
||||
// deposits TokenID: 0
|
||||
CreateAccountDeposit(0) B: 10000
|
||||
CreateAccountDeposit(0) C: 1
|
||||
|
||||
> batchL1
|
||||
|
||||
@@ -67,11 +78,12 @@ Transfer(1) G-K: 3 (1)
|
||||
Transfer(1) H-K: 3 (2)
|
||||
Transfer(1) H-K: 3 (1)
|
||||
Transfer(1) H-K: 3 (1)
|
||||
Transfer(0) B-C: 50 (192)
|
||||
|
||||
> batchL1
|
||||
> block
|
||||
// A (3) still does not exist, coordinator should create new L1Tx to create the account
|
||||
CreateAccountDepositCoordinator(3) A
|
||||
CreateAccountCoordinator(3) A
|
||||
|
||||
Transfer(3) B-A: 5 (1)
|
||||
Transfer(2) A-B: 5 (1)
|
||||
@@ -156,7 +168,7 @@ Transfer(1) I-H: 5 (1)
|
||||
Exit(1) A: 5 (1)
|
||||
|
||||
// create CoordinatorTx CreateAccount for D, TokenId 2, used at SetPool0 for 'PoolTransfer(2) B-D: 3 (1)'
|
||||
CreateAccountDepositCoordinator(2) D
|
||||
CreateAccountCoordinator(2) D
|
||||
|
||||
> batchL1
|
||||
> batchL1
|
||||
|
||||
@@ -219,6 +219,26 @@ func (tc *Context) GenerateBlocks(set string) ([]common.BlockData, error) {
|
||||
L2Tx: tx,
|
||||
}
|
||||
tc.currBatchTest.l2Txs = append(tc.currBatchTest.l2Txs, testTx)
|
||||
case common.TxTypeForceTransfer: // tx source: L1UserTx
|
||||
if err := tc.checkIfTokenIsRegistered(inst); err != nil {
|
||||
log.Error(err)
|
||||
return nil, fmt.Errorf("Line %d: %s", inst.lineNum, err.Error())
|
||||
}
|
||||
tx := common.L1Tx{
|
||||
TokenID: inst.tokenID,
|
||||
Amount: big.NewInt(int64(inst.amount)),
|
||||
LoadAmount: big.NewInt(0),
|
||||
Type: common.TxTypeForceTransfer,
|
||||
}
|
||||
testTx := L1Tx{
|
||||
lineNum: inst.lineNum,
|
||||
fromIdxName: inst.from,
|
||||
toIdxName: inst.to,
|
||||
L1Tx: tx,
|
||||
}
|
||||
if err := tc.addToL1Queue(testTx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case common.TxTypeExit: // tx source: L2Tx
|
||||
if err := tc.checkIfTokenIsRegistered(inst); err != nil {
|
||||
log.Error(err)
|
||||
@@ -248,7 +268,7 @@ func (tc *Context) GenerateBlocks(set string) ([]common.BlockData, error) {
|
||||
TokenID: inst.tokenID,
|
||||
Amount: big.NewInt(int64(inst.amount)),
|
||||
LoadAmount: big.NewInt(0),
|
||||
Type: common.TxTypeExit,
|
||||
Type: common.TxTypeForceExit,
|
||||
}
|
||||
testTx := L1Tx{
|
||||
lineNum: inst.lineNum,
|
||||
@@ -415,7 +435,7 @@ func (tc *Context) addToL1Queue(tx L1Tx) error {
|
||||
}
|
||||
tx.L1Tx.ToIdx = account.Idx
|
||||
}
|
||||
if tx.L1Tx.Type == common.TxTypeExit {
|
||||
if tx.L1Tx.Type == common.TxTypeForceExit {
|
||||
tx.L1Tx.ToIdx = common.Idx(1)
|
||||
}
|
||||
nTx, err := common.NewL1Tx(&tx.L1Tx)
|
||||
|
||||
@@ -54,8 +54,8 @@ func TestGenerateBlocks(t *testing.T) {
|
||||
|
||||
// set new batch
|
||||
> batch // batchNum = 3
|
||||
CreateAccountDepositCoordinator(1) E
|
||||
CreateAccountDepositCoordinator(2) B
|
||||
CreateAccountCoordinator(1) E
|
||||
CreateAccountCoordinator(2) B
|
||||
|
||||
DepositTransfer(1) A-B: 15, 10
|
||||
Transfer(1) C-A : 3 (1)
|
||||
@@ -64,8 +64,8 @@ func TestGenerateBlocks(t *testing.T) {
|
||||
|
||||
CreateAccountDeposit(1) User0: 20
|
||||
CreateAccountDeposit(3) User1: 20
|
||||
CreateAccountDepositCoordinator(1) User1
|
||||
CreateAccountDepositCoordinator(3) User0
|
||||
CreateAccountCoordinator(1) User1
|
||||
CreateAccountCoordinator(3) User0
|
||||
> batchL1 // batchNum = 4
|
||||
Transfer(1) User0-User1: 15 (1)
|
||||
Transfer(3) User1-User0: 15 (1)
|
||||
@@ -329,7 +329,7 @@ func TestGenerateErrors(t *testing.T) {
|
||||
AddToken(1)
|
||||
CreateAccountDeposit(1) A: 10
|
||||
> batchL1
|
||||
CreateAccountDepositCoordinator(1) B
|
||||
CreateAccountCoordinator(1) B
|
||||
> batchL1
|
||||
> batch
|
||||
Transfer(1) A-B: 6 (1)
|
||||
@@ -345,7 +345,7 @@ func TestGenerateErrors(t *testing.T) {
|
||||
AddToken(1)
|
||||
CreateAccountDeposit(1) A: 10
|
||||
> batchL1
|
||||
CreateAccountDepositCoordinator(1) B
|
||||
CreateAccountCoordinator(1) B
|
||||
> batchL1
|
||||
Transfer(1) A-B: 6 (1)
|
||||
Transfer(1) A-B: 6 (1) // on purpose this is moving more money that what it has in the account, Til should not fail
|
||||
|
||||
Reference in New Issue
Block a user