public void Tip(StoreType storeType) { Block <NCAction> genesisBlock = BlockChain <NCAction> .MakeGenesisBlock(); IStore store = storeType.CreateStore(_storePath); Guid chainId = Guid.NewGuid(); store.SetCanonicalChainId(chainId); store.PutBlock(genesisBlock); store.AppendIndex(chainId, genesisBlock.Hash); (store as IDisposable)?.Dispose(); _command.Tip(storeType, _storePath); Assert.Equal(JsonSerializer.Serialize(genesisBlock.Header) + "\n", _console.Out.ToString()); }
public void Tip(StoreType storeType) { HashAlgorithmType hashAlgo = HashAlgorithmType.Of <SHA256>(); Block <NCAction> genesisBlock = BlockChain <NCAction> .MakeGenesisBlock(hashAlgo); IStore store = storeType.CreateStore(_storePath); Guid chainId = Guid.NewGuid(); store.SetCanonicalChainId(chainId); store.PutBlock(genesisBlock); store.AppendIndex(chainId, genesisBlock.Hash); store.Dispose(); // FIXME For an unknown reason, BlockHeader.TimeStamp precision issue occurred and the store we should open it again. store = storeType.CreateStore(_storePath); genesisBlock = store.GetBlock <NCAction>(_ => hashAlgo, genesisBlock.Hash); store.Dispose(); _command.Tip(storeType, _storePath); Assert.Equal( Utils.SerializeHumanReadable(genesisBlock.Header), _console.Out.ToString().Trim() ); }