Exemplo n.º 1
0
        protected (Block block, Transaction transaction) PrepareTx(
            long blockNumber,
            long gasLimit,
            byte[] code,
            SenderRecipientAndMiner senderRecipientAndMiner = null)
        {
            senderRecipientAndMiner ??= SenderRecipientAndMiner.Default;
            TestState.CreateAccount(senderRecipientAndMiner.Sender, 100.Ether());
            TestState.CreateAccount(senderRecipientAndMiner.Recipient, 100.Ether());
            Keccak codeHash = TestState.UpdateCode(code);

            TestState.UpdateCodeHash(senderRecipientAndMiner.Recipient, codeHash, SpecProvider.GenesisSpec);

            TestState.Commit(SpecProvider.GenesisSpec);
            TestState.CommitTree();

            Transaction transaction = Build.A.Transaction
                                      .WithGasLimit(gasLimit)
                                      .WithGasPrice(1)
                                      .To(senderRecipientAndMiner.Recipient)
                                      .SignedAndResolved(_ethereumEcdsa, senderRecipientAndMiner.SenderKey)
                                      .TestObject;

            Block block = BuildBlock(blockNumber, senderRecipientAndMiner, transaction);

            return(block, transaction);
        }
Exemplo n.º 2
0
        protected override Block BuildBlock(long blockNumber, SenderRecipientAndMiner senderRecipientAndMiner)
        {
            Block block = base.BuildBlock(blockNumber, senderRecipientAndMiner);

            if (_setAuthor)
            {
                block.Header.Author = TestItem.AddressC;
            }
            block.Header.Beneficiary = TestItem.AddressB;
            return(block);
        }
Exemplo n.º 3
0
        protected override Block BuildBlock(long blockNumber, SenderRecipientAndMiner senderRecipientAndMiner, Transaction transaction, long blockGasLimit = DefaultBlockGasLimit)
        {
            Block block = base.BuildBlock(blockNumber, senderRecipientAndMiner, transaction, blockGasLimit);

            if (_setAuthor)
            {
                block.Header.Author = TestItem.AddressC;
            }
            block.Header.Beneficiary = TestItem.AddressB;
            return(block);
        }
Exemplo n.º 4
0
        protected override Block BuildBlock(long blockNumber, SenderRecipientAndMiner senderRecipientAndMiner, Transaction transaction)
        {
            senderRecipientAndMiner ??= new SenderRecipientAndMiner();
            Block block = base.BuildBlock(blockNumber, senderRecipientAndMiner, transaction);

            if (_setAuthor)
            {
                block.Header.Author = TestItem.AddressC;
            }
            block.Header.Beneficiary = senderRecipientAndMiner.Recipient;
            return(block);
        }
Exemplo n.º 5
0
 protected virtual Block BuildBlock(long blockNumber, SenderRecipientAndMiner senderRecipientAndMiner, Transaction tx)
 {
     senderRecipientAndMiner ??= SenderRecipientAndMiner.Default;
     return(Build.A.Block.WithNumber(blockNumber).WithTransactions(tx == null ? new Transaction[0] : new[] { tx }).WithGasLimit(8000000).WithBeneficiary(senderRecipientAndMiner.Miner).TestObject);
 }
Exemplo n.º 6
0
 protected Block BuildBlock(long blockNumber, SenderRecipientAndMiner senderRecipientAndMiner)
 {
     return(BuildBlock(blockNumber, senderRecipientAndMiner, null));
 }
Exemplo n.º 7
0
        protected (Block block, Transaction transaction) PrepareInitTx(long blockNumber, long gasLimit, byte[] code, SenderRecipientAndMiner senderRecipientAndMiner = null)
        {
            senderRecipientAndMiner ??= SenderRecipientAndMiner.Default;
            TestState.CreateAccount(senderRecipientAndMiner.Sender, 100.Ether());
            TestState.Commit(SpecProvider.GenesisSpec);

            Transaction transaction = Build.A.Transaction
                                      .WithTo(null)
                                      .WithData(Array.Empty <byte>())
                                      .WithGasLimit(gasLimit)
                                      .WithGasPrice(1)
                                      .WithInit(code)
                                      .SignedAndResolved(_ethereumEcdsa, senderRecipientAndMiner.SenderKey)
                                      .TestObject;

            Block block = BuildBlock(blockNumber, senderRecipientAndMiner);

            return(block, transaction);
        }
Exemplo n.º 8
0
 protected virtual Block BuildBlock(long blockNumber, SenderRecipientAndMiner senderRecipientAndMiner)
 {
     senderRecipientAndMiner ??= SenderRecipientAndMiner.Default;
     return(Build.A.Block.WithNumber(blockNumber).WithGasLimit(8000000).WithBeneficiary(senderRecipientAndMiner.Miner).TestObject);
 }