Documentation ¶
Index ¶
- Constants
- Variables
- func L1TxsToCommonL1Txs(l1 []L1Tx) []common.L1Tx
- type Account
- type ConfigExtra
- type Context
- func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra) error
- func (tc *Context) FillBlocksForgedL1UserTxs(blocks []common.BlockData) error
- func (tc *Context) FillBlocksL1UserTxsBatchNum(blocks []common.BlockData)
- func (tc *Context) GenerateBlocks(set string) ([]common.BlockData, error)
- func (tc *Context) GenerateBlocksFromInstructions(set []Instruction) ([]common.BlockData, error)
- func (tc *Context) GeneratePoolL2Txs(set string) ([]common.PoolL2Tx, error)
- func (tc *Context) GeneratePoolL2TxsFromInstructions(set []Instruction) ([]common.PoolL2Tx, error)
- func (tc *Context) RestartNonces()
- type Instruction
- type L1Tx
- type L2Tx
- type User
Constants ¶
const ( ILLEGAL token = iota WS EOF IDENT // val )
nolint
Variables ¶
var SetTypeBlockchain = setType("Blockchain")
SetTypeBlockchain defines the type 'Blockchain' of the set
var SetTypePoolL2 = setType("PoolL2")
SetTypePoolL2 defines the type 'PoolL2' of the set
var TxTypeCreateAccountDepositCoordinator common.TxType = "TypeCreateAccountDepositCoordinator"
TxTypeCreateAccountDepositCoordinator is used for testing purposes only, and represents the common.TxType of a create acount deposit made by the coordinator
var TypeAddToken common.TxType = "InstrTypeAddToken" //nolint:gosec
TypeAddToken is used for testing purposes only, and represents the common.TxType of a new Token regsitration. It has 'nolint:gosec' as the string 'Token' triggers gosec as a potential leaked Token (which is not the case).
var TypeNewBatch common.TxType = "InstrTypeNewBatch"
TypeNewBatch is used for testing purposes only, and represents the common.TxType of a new batch
var TypeNewBatchL1 common.TxType = "InstrTypeNewBatchL1"
TypeNewBatchL1 is used for testing purposes only, and represents the common.TxType of a new batch
var TypeNewBlock common.TxType = "InstrTypeNewBlock"
TypeNewBlock is used for testing purposes only, and represents the common.TxType of a new ethereum block
Functions ¶
func L1TxsToCommonL1Txs ¶
L1TxsToCommonL1Txs converts an array of []til.L1Tx to []common.L1Tx
Types ¶
type ConfigExtra ¶
type ConfigExtra struct { // Address to set as forger for each batch BootCoordAddr ethCommon.Address // Coordinator user name used to select the corresponding accounts to // collect coordinator fees CoordUser string }
ConfigExtra is the configuration used in FillBlocksExtra to extend the blocks returned by til.
type Context ¶
type Context struct { Users map[string]*User // Name -> *User UsersByIdx map[int]*User LastRegisteredTokenID common.TokenID Queues [][]L1Tx ToForgeNum int // contains filtered or unexported fields }
Context contains the data of the test
func NewContext ¶
NewContext returns a new Context
func (*Context) FillBlocksExtra ¶
func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra) error
FillBlocksExtra fills extra fields not generated by til in each block, so that the blockData is closer to what the HistoryDB stores. The filled fields are: - blocks[].Rollup.Batch.EthBlockNum - blocks[].Rollup.Batch.ForgerAddr - blocks[].Rollup.Batch.ForgeL1TxsNum - blocks[].Rollup.Batch.L1CoordinatorTxs[].TxID - blocks[].Rollup.Batch.L1CoordinatorTxs[].BatchNum - blocks[].Rollup.Batch.L1CoordinatorTxs[].EthBlockNum - blocks[].Rollup.Batch.L1CoordinatorTxs[].Position - blocks[].Rollup.Batch.L1CoordinatorTxs[].EffectiveAmount - blocks[].Rollup.Batch.L1CoordinatorTxs[].EffectiveDepositAmount - blocks[].Rollup.Batch.L1CoordinatorTxs[].EffectiveFromIdx - blocks[].Rollup.Batch.L2Txs[].TxID - blocks[].Rollup.Batch.L2Txs[].Position - blocks[].Rollup.Batch.L2Txs[].Nonce - blocks[].Rollup.Batch.L2Txs[].TokenID - blocks[].Rollup.Batch.ExitTree - blocks[].Rollup.Batch.CreatedAccounts - blocks[].Rollup.Batch.FeeIdxCoordinator - blocks[].Rollup.Batch.CollectedFees
func (*Context) FillBlocksForgedL1UserTxs ¶
FillBlocksForgedL1UserTxs fills the L1UserTxs of a batch with the L1UserTxs that are forged in that batch. It always sets `EffectiveAmount` = `Amount` and `EffectiveDepositAmount` = `DepositAmount`. This function requires a previous call to `FillBlocksExtra`. - blocks[].Rollup.L1UserTxs[].BatchNum - blocks[].Rollup.L1UserTxs[].EffectiveAmount - blocks[].Rollup.L1UserTxs[].EffectiveDepositAmount - blocks[].Rollup.L1UserTxs[].EffectiveFromIdx
func (*Context) FillBlocksL1UserTxsBatchNum ¶
FillBlocksL1UserTxsBatchNum fills the BatchNum of forged L1UserTxs: - blocks[].Rollup.L1UserTxs[].BatchNum
func (*Context) GenerateBlocks ¶
GenerateBlocks returns an array of BlockData for a given set made of a string. It uses the users (keys & nonces) of the Context.
func (*Context) GenerateBlocksFromInstructions ¶
func (tc *Context) GenerateBlocksFromInstructions(set []Instruction) ([]common.BlockData, error)
GenerateBlocksFromInstructions returns an array of BlockData for a given set made of instructions. It uses the users (keys & nonces) of the Context.
func (*Context) GeneratePoolL2Txs ¶
GeneratePoolL2Txs returns an array of common.PoolL2Tx from a given set made of a string. It uses the users (keys) of the Context.
func (*Context) GeneratePoolL2TxsFromInstructions ¶
func (tc *Context) GeneratePoolL2TxsFromInstructions(set []Instruction) ([]common.PoolL2Tx, error)
GeneratePoolL2TxsFromInstructions returns an array of common.PoolL2Tx from a given set made of instructions. It uses the users (keys) of the Context.
func (*Context) RestartNonces ¶
func (tc *Context) RestartNonces()
RestartNonces sets all the Users.Accounts.Nonces to 0
type Instruction ¶
type Instruction struct { LineNum int Literal string From string To string Amount *big.Int DepositAmount *big.Int Fee uint8 TokenID common.TokenID Typ common.TxType // D: Deposit, T: Transfer, E: ForceExit }
Instruction is the data structure that represents one line of code
func (Instruction) String ¶
func (i Instruction) String() string
type L1Tx ¶
L1Tx is the data structure used internally for transaction test generation, which contains a common.L1Tx data plus some intermediate data for the transaction generation.
type L2Tx ¶
L2Tx is the data structure used internally for transaction test generation, which contains a common.L2Tx data plus some intermediate data for the transaction generation.