Example #1
0
        public async Task BinaryCacheTestAsync()
        {
            /*
             * Explicit blockchain name test
             */

            // Act - Create a binary cache
            var expCache = await _utility.CreateBinaryCacheAsync(_chainName, id : UUID.NoHyphens);

            // Assert
            Assert.IsTrue(expCache.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <string> >(expCache);

            // Act - Append to binary cache
            var expAppend = await _utility.AppendBinaryCacheAsync(_chainName, UUID.NoHyphens, expCache.Result,
                                                                  "Some string data we can use to generate dat hex content. An then a bit more at the end".ToHex());

            // Assert
            Assert.IsTrue(expAppend.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <int> >(expAppend);

            // Act - Delete binary cache
            var expDelete = await _utility.DeleteBinaryCacheAsync(_chainName, UUID.NoHyphens, expCache.Result);

            // Assert
            Assert.IsTrue(expDelete.IsSuccess());
            Assert.IsInstanceOf <RpcResponse>(expDelete);

            /*
             * Inferred blockchain name test
             */

            // Act - Create a binary cache
            var infCache = await _utility.CreateBinaryCacheAsync();

            // Assert
            Assert.IsTrue(infCache.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <string> >(infCache);

            // Act - Append to binary cache
            var infAppend = await _utility.AppendBinaryCacheAsync(infCache.Result,
                                                                  "Some string data we can use to generate dat hex content. An then a bit more at the end".ToHex());

            // Assert
            Assert.IsTrue(infAppend.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <int> >(infAppend);

            // Act - Delete binary cache
            var infDelete = await _utility.DeleteBinaryCacheAsync(infCache.Result);

            // Assert
            Assert.IsTrue(infDelete.IsSuccess());
            Assert.IsInstanceOf <RpcResponse>(infDelete);
        }
        public async Task TxOutToBinaryCacheTestAsync()
        {
            /*
             * Explicit blockchain name test
             */

            // Stage
            var expBinaryCache = await _utility.CreateBinaryCacheAsync(_chainName, UUID.NoHyphens);

            var expPublish = await _wallet.PublishFromAsync(_chainName, UUID.NoHyphens, _address, "root", ChainEntity.GetUUID(), "A bunch of text data that will be transcribed to this this publish event and this one is async brotato chip".ToHex(), "");

            var expTransaction = await _wallet.GetAddressTransactionAsync(_chainName, UUID.NoHyphens, _address, expPublish.Result, true);

            // Act
            var exp = await _wallet.TxOutToBinaryCacheAsync(_chainName, UUID.NoHyphens, expBinaryCache.Result, expTransaction.Result.Txid, expTransaction.Result.Vout[0].N, 100000, 0);

            // Clean-up
            await _utility.DeleteBinaryCacheAsync(_chainName, UUID.NoHyphens, expBinaryCache.Result);

            // Assert
            Assert.IsTrue(exp.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <double> >(exp);

            /*
             * Inferred blockchain name test
             */

            // Stage
            var infBinaryCache = await _utility.CreateBinaryCacheAsync();

            var infPublish = await _wallet.PublishFromAsync(_address, "root", ChainEntity.GetUUID(), "A bunch of text data that will be transcribed to this this publish event and this one is async brotato chip".ToHex(), "");

            var infTransaction = await _wallet.GetAddressTransactionAsync(_address, infPublish.Result, true);

            // Act
            var inf = await _wallet.TxOutToBinaryCacheAsync(infBinaryCache.Result, infTransaction.Result.Txid, infTransaction.Result.Vout[0].N, 100000, 0);

            // Clean-up
            await _utility.DeleteBinaryCacheAsync(infBinaryCache.Result);

            // Assert
            Assert.IsTrue(inf.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <double> >(inf);
        }