BitSharper.Test.ChainSplitTests.TestForking4 C# (CSharp) 메소드

TestForking4() 개인적인 메소드

private TestForking4 ( ) : void
리턴 void
        public void TestForking4()
        {
            // Check that we can handle external spends on an inactive chain becoming active. An external spend is where
            // we see a transaction that spends our own coins but we did not broadcast it ourselves. This happens when
            // keys are being shared between wallets.
            var b1 = _unitTestParams.GenesisBlock.CreateNextBlock(_coinbaseTo);
            _chain.Add(b1);
            Assert.AreEqual("50.00", Utils.BitcoinValueToFriendlyString(_wallet.GetBalance()));
            var dest = new EcKey().ToAddress(_unitTestParams);
            var spend = _wallet.CreateSend(dest, Utils.ToNanoCoins(50, 0));
            // We do NOT confirm the spend here. That means it's not considered to be pending because createSend is
            // stateless. For our purposes it is as if some other program with our keys created the tx.
            //
            // genesis -> b1 (receive 50) --> b2
            //                            \-> b3 (external spend) -> b4
            var b2 = b1.CreateNextBlock(_someOtherGuy);
            _chain.Add(b2);
            var b3 = b1.CreateNextBlock(_someOtherGuy);
            b3.AddTransaction(spend);
            b3.Solve();
            _chain.Add(b3);
            // The external spend is not active yet.
            Assert.AreEqual(Utils.ToNanoCoins(50, 0), _wallet.GetBalance());
            var b4 = b3.CreateNextBlock(_someOtherGuy);
            _chain.Add(b4);
            // The external spend is now active.
            Assert.AreEqual(Utils.ToNanoCoins(0, 0), _wallet.GetBalance());
        }