src/Stratis.FederatedPeg.Tests/CrossChainTransferStoreTests.cs
/// <summary>
/// Test that after synchronizing with the chain the store tip equals the chain tip.
/// </summary>
Test that after synchronizing with the chain the store tip equals the chain tip.
Test that after synchronizing with the chain the store tip equals the chain tip .
[Fact]
        public void StartSynchronizesWithWalletAndSurvivesRestart()
        {
            var dataFolder = new DataFolder(CreateTestDir(this));
            this.Init(dataFolder);
            this.AppendBlocks(this.federationGatewaySettings.MinCoinMaturity);
            using (ICrossChainTransferStore crossChainTransferStore = this.CreateStore())
            {
                crossChainTransferStore.Initialize();
                crossChainTransferStore.Start();
                this.federationWalletManager.SaveWallet();
                Assert.Equal(this.wallet.LastBlockSyncedHash, crossChainTransferStore.TipHashAndHeight.HashBlock);
                Assert.Equal(this.wallet.LastBlockSyncedHeight, crossChainTransferStore.TipHashAndHeight.Height);
            }
            var newTest = new CrossChainTransferStoreTests(this.network);
            newTest.Init(dataFolder);
            newTest.AppendBlocks(3);
            using (ICrossChainTransferStore crossChainTransferStore2 = newTest.CreateStore())
            {
                crossChainTransferStore2.Initialize();
                crossChainTransferStore2.Start();
                Assert.Equal(newTest.wallet.LastBlockSyncedHash, crossChainTransferStore2.TipHashAndHeight.HashBlock);
                Assert.Equal(newTest.wallet.LastBlockSyncedHeight, crossChainTransferStore2.TipHashAndHeight.Height);
            }
        }
[ Fact ] public void StartSynchronizesWithWalletAndSurvivesRestart ( ) { var dataFolder = new DataFolder ( CreateTestDir ( this ) ) ; this . Init ( dataFolder ) ; this . AppendBlocks ( this . federationGatewaySettings . MinCoinMaturity ) ; using ( ICrossChainTransferStore crossChainTransferStore = this . CreateStore ( ) ) { crossChainTransferStore . Initialize ( ) ; crossChainTransferStore . Start ( ) ; this . federationWalletManager . SaveWallet ( ) ; Assert . Equal ( this . wallet . LastBlockSyncedHash , crossChainTransferStore . TipHashAndHeight . HashBlock ) ; Assert . Equal ( this . wallet . LastBlockSyncedHeight , crossChainTransferStore . TipHashAndHeight . Height ) ; } var newTest = new CrossChainTransferStoreTests ( this . network ) ; newTest . Init ( dataFolder ) ; newTest . AppendBlocks ( 3 ) ; using ( ICrossChainTransferStore crossChainTransferStore2 = newTest . CreateStore ( ) ) { crossChainTransferStore2 . Initialize ( ) ; crossChainTransferStore2 . Start ( ) ; Assert . Equal ( newTest . wallet . LastBlockSyncedHash , crossChainTransferStore2 . TipHashAndHeight . HashBlock ) ; Assert . Equal ( newTest . wallet . LastBlockSyncedHeight , crossChainTransferStore2 . TipHashAndHeight . Height ) ; } }
Test that after synchronizing with the chain the store tip equals the chain tip.
Test that after synchronizing with the chain the store tip equals the chain tip .
// Create a new instance of this test that loads from the persistence that we created in the step before. // Force a reorg by creating a new chain that only has genesis in common. // Test that synchronizing the store aligns it with the current chain tip after the fork.