Exemple #1
0
        public PoAMockChain Build()
        {
            for (int nodeIndex = 0; nodeIndex < this.nodes.Length; nodeIndex++)
            {
                CoreNode node = this.nodeFactory(nodeIndex);

                for (int j = 0; j < nodeIndex; j++)
                {
                    MockChainNode otherNode = this.nodes[j];
                    TestHelper.Connect(node, otherNode.CoreNode);
                }

                this.nodes[nodeIndex] = new MockChainNode(node, this, this.initMnemonic);
            }

            return(this);
        }
Exemple #2
0
        public PoAMockChain Build()
        {
            var network = new SmartContractsPoARegTest();

            for (int nodeIndex = 0; nodeIndex < this.nodes.Length; nodeIndex++)
            {
                CoreNode node = this.builder.CreateSmartContractPoANode(network, nodeIndex).Start();

                for (int j = 0; j < nodeIndex; j++)
                {
                    MockChainNode otherNode = this.nodes[j];
                    TestHelper.Connect(node, otherNode.CoreNode);
                }

                this.nodes[nodeIndex] = new MockChainNode(node, this, this.initMnemonic);
            }

            return(this);
        }
Exemple #3
0
        public PoWMockChain(int numberOfNodes)
        {
            this.height  = 0;
            this.builder = SmartContractNodeBuilder.Create(this);
            this.nodes   = new MockChainNode[numberOfNodes];

            for (int nodeIndex = 0; nodeIndex < numberOfNodes; nodeIndex++)
            {
                CoreNode node = this.builder.CreateSmartContractPowNode().Start();

                for (int j = 0; j < nodeIndex; j++)
                {
                    MockChainNode otherNode = this.nodes[j];
                    TestHelper.Connect(node, otherNode.CoreNode);
                }

                this.nodes[nodeIndex] = new MockChainNode(node, this);
            }
        }
Exemple #4
0
        public PoAMockChainFixture()
        {
            PoAMockChain mockChain = new PoAMockChain(2).Build();

            this.Chain = mockChain;
            MockChainNode node1 = this.Chain.Nodes[0];
            MockChainNode node2 = this.Chain.Nodes[1];

            // Get premine
            mockChain.MineBlocks(10);

            // Send half to other from whoever received premine
            if ((long)node1.WalletSpendableBalance == node1.CoreNode.FullNode.Network.Consensus.PremineReward.Satoshi)
            {
                this.PayHalfPremine(node1, node2);
            }
            else
            {
                this.PayHalfPremine(node2, node1);
            }
        }
 private void PayHalfPremine(MockChainNode from, MockChainNode to)
 {
     from.SendTransaction(to.MinerAddress.ScriptPubKey, new Money(from.CoreNode.FullNode.Network.Consensus.PremineReward.Satoshi / 2, MoneyUnit.Satoshi));
     from.WaitMempoolCount(1);
     this.Chain.MineBlocks(1);
 }