github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/test/vectors/vectors.go (about)

     1  package vectors
     2  
     3  import (
     4  	"math/big"
     5  
     6  	"github.com/ethereum/go-ethereum/common"
     7  )
     8  
     9  // StateTransitionTestCase holds the metadata needed to run a state transition test
    10  type StateTransitionTestCase struct {
    11  	ID                  uint   `json:"id"`
    12  	Description         string `json:"description"`
    13  	ChainIDSequencer    uint64 `json:"chainIdSequencer"`
    14  	SequencerAddress    string `json:"sequencerAddress"`
    15  	SequencerPrivateKey string `json:"sequencerPvtKey"`
    16  
    17  	GenesisAccounts       []GenesisAccount       `json:"genesis"`
    18  	GenesisSmartContracts []GenesisSmartContract `json:"genesisSC"`
    19  	ExpectedOldRoot       string                 `json:"expectedOldRoot"`
    20  	Txs                   []Tx                   `json:"txs"`
    21  	ExpectedNewRoot       string                 `json:"expectedNewRoot"`
    22  	ExpectedNewLeafs      map[string]Leaf        `json:"expectedNewLeafs"`
    23  	Receipts              []TestReceipt          `json:"receipts"`
    24  	GlobalExitRoot        string                 `json:"globalExitRoot"`
    25  }
    26  
    27  // GenesisAccount represents the state of an account when the network
    28  // starts
    29  type GenesisAccount struct {
    30  	Address string    `json:"address"`
    31  	PvtKey  string    `json:"pvtKey"`
    32  	Balance argBigInt `json:"balance"`
    33  	Nonce   string    `json:"nonce"`
    34  }
    35  
    36  // GenesisSmartContract represents the smart contract to init when the network starts
    37  type GenesisSmartContract struct {
    38  	Address string `json:"address"`
    39  	Code    string `json:"bytecode"`
    40  }
    41  
    42  // Tx represents a transactions that will be applied during the test
    43  type Tx struct {
    44  	ID                uint       `json:"id"`
    45  	From              string     `json:"from"`
    46  	To                string     `json:"to"`
    47  	Nonce             uint64     `json:"nonce"`
    48  	Value             *big.Float `json:"value"`
    49  	GasLimit          uint64     `json:"gasLimit"`
    50  	GasPrice          *big.Float `json:"gasPrice"`
    51  	ChainID           uint64     `json:"chainId"`
    52  	RawTx             string     `json:"rawTx"`
    53  	Overwrite         Overwrite  `json:"overwrite"`
    54  	EncodeInvalidData bool       `json:"encodeInvalidData"`
    55  	Reason            string     `json:"reason"`
    56  }
    57  
    58  // Leaf represents the state of a leaf in the merkle tree
    59  type Leaf struct {
    60  	Balance argBigInt `json:"balance"`
    61  	Nonce   string    `json:"nonce"`
    62  }
    63  
    64  // Overwrite is used by Protocol team for testing
    65  type Overwrite struct {
    66  	S string `json:"s"`
    67  }
    68  
    69  // TxEventsSendBatchTestCase holds the metadata needed to run a etherman test
    70  type TxEventsSendBatchTestCase struct {
    71  	ID  uint `json:"id"`
    72  	Txs []Tx `json:"txs"`
    73  
    74  	BatchL2Data   string      `json:"batchL2Data"`
    75  	BatchHashData common.Hash `json:"batchHashData"`
    76  	MaticAmount   string      `json:"maticAmount"`
    77  	FullCallData  string      `json:"fullCallData"`
    78  }
    79  
    80  // TestReceipt holds the metadata needed to run the receipt tests
    81  type TestReceipt struct {
    82  	TxID    uint    `json:"txId"`
    83  	Receipt Receipt `json:"receipt"`
    84  }
    85  
    86  // Receipt is the receipt used for receipts tests
    87  type Receipt struct {
    88  	TransactionHash    string `json:"transactionHash"`
    89  	TransactionIndex   uint   `json:"transactionIndex"`
    90  	BlockNumber        uint64 `json:"blockNumber"`
    91  	From               string `json:"from"`
    92  	To                 string `json:"to"`
    93  	CumulativeGastUsed uint64 `json:"cumulativeGasUsed"`
    94  	GasUsedForTx       uint64 `json:"gasUsedForTx"`
    95  	ContractAddress    string `json:"contractAddress"`
    96  	Logs               uint64 `json:"logs"`
    97  	LogsBloom          uint64 `json:"logsBloom"`
    98  	Status             uint64 `json:"status"`
    99  	BlockHash          string `json:"blockHash"`
   100  }