public async Task Provided_Input_Should_Make_Transfer_Transaction_And_PostCommit()
        {
            string id = "282137f67ce65e34a9eb13145606d7bf87bdaf9174111d6053002bfc543575c8";

            var generatekp = new Ed25519Keypair();
            var keys       = generatekp.GenerateKeyPair();

            var connection   = new BigchainConnection(bigchainhost);
            var currentBlock = await connection.ListBlocks(id);

            Bigchain_Transaction transaction = new Bigchain_Transaction();
            var metadata = new Metadata
            {
                Error       = null,
                Status      = "A",
                Transaction = null
            };

            currentBlock.Metadata = JObject.FromObject(metadata);


            var unspentOutput = new UnspentOutput {
                Tx          = currentBlock,
                OutputIndex = 0
            };

            var Outputs = transaction.MakeOutput(Asn1ConditionsHelper.MakeEd25519Condition(currentBlock.Outputs[0].PublicKeys[0]));

            var tx = transaction.MakeTransferTransaction(new List <UnspentOutput> {
                unspentOutput
            },
                                                         Outputs,
                                                         metadata
                                                         );
            var signTransaction = new Bigchain_SignTransaction();
            var signedTx        = signTransaction.SignTransaction(tx, new List <string>()
            {
                keys.ExpandedPrivateKey
            });
            var serializedTransaction = JsonUtility.SerializeTransactionIntoCanonicalString(JsonConvert.SerializeObject(signedTx));

            Assert.Pass();
        }
Beispiel #2
0
        public void Provided_Payload_Should_Return_ValidSerializedTx()
        {
            var keyPair = new GeneratedKeyPair()
            {
                ExpandedPrivateKey = "2SmR42zKeTExHeXa5gFCJzfVLzPb843bkv9L9EGNxfABo9roeGWuNvTg5KFCcNoA6xd4VnWnX1yzALSvszBFncGu",
                PrivateKey         = "5ryt9DgJWu2G5Ptzd5CwUXsvw5DKygd4serdMoJ67KCm",
                PublicKey          = "6up1UDJC2EnReHcdYVZkJdR8hbSym48P5XWiyD1oW2Qm"
            };

            var expectedHash = "1a7e241014157ffaca8b854c6775186b581d2058a6299b6d4e79437fce4979fc";

            var tx = GetMockResponseTx(keyPair.PublicKey);

            var signTx   = new Bigchain_SignTransaction();
            var signedTx = signTx.SignTransaction(tx, new List <string> {
                keyPair.ExpandedPrivateKey
            });
            var serializedTx = JsonUtility.SerializeTransactionIntoCanonicalString(JsonConvert.SerializeObject(signedTx));

            Assert.AreEqual(expectedHash, signedTx.Id);
        }