Exemple #1
0
        public void Should_Deserialize_The_Transaction_With_A_Passphrase()
        {
            var fixture     = TestHelper.ReadTransactionFixture("timelock_transfer", "passphrase");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(transaction["id"], actual.Id);
        }
        public void Serialize()
        {
            var fixture     = TestHelper.ReadTransactionFixture("transfer", "passphrase");
            var transaction = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            var serializedTransaction = transaction.Serialize();

            Assert.AreEqual(fixture["serialized"], Encoders.Hex.EncodeData(serializedTransaction));
        }
        public void Should_Serialize_The_Transaction()
        {
            var fixture     = TestHelper.ReadTransactionFixture("delegate_resignation", "passphrase");
            var transaction = fixture["data"];

            var transactionModel = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();
            var actual           = new Crypto.Transactions.Serializer(transactionModel).Serialize();

            Assert.AreEqual(fixture["serialized"], Encoders.Hex.EncodeData(actual));
        }
        public void ToJson()
        {
            var expectedJson = "{\"amount\":200000000,\"asset\":{},\"fee\":10000000,\"id\":\"da61c6cba363cc39baa0ca3f9ba2c5db81b9805045bd0b9fc58af07ad4206856\",\"network\":30,\"recipientId\":\"D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib\",\"secondSignature\":null,\"senderPublicKey\":\"034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192\",\"signature\":\"3044022002994b30e08b58825c8c16ebf2cc693cfe706fb26571674784ead098accc89d702205b79dedc752a84504ecfe4b9e1292997f22260ee4daa102d2d9a61432d93b286\",\"signatures\":null,\"signSignature\":null,\"timestamp\":41268326,\"type\":0,\"vendorField\":null,\"version\":1}";

            var fixture     = TestHelper.ReadTransactionFixture("transfer", "passphrase");
            var transaction = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();
            var json        = transaction.ToJson();

            Assert.AreEqual(expectedJson, json);
        }
        public void Should_Deserialize_The_Transaction_With_A_Passphrase()
        {
            var fixture     = TestHelper.ReadTransactionFixture("delegate_registration", "passphrase");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(1, actual.Version);
            Assert.AreEqual(30, actual.Network);
            Assert.AreEqual((byte)transaction["type"], actual.Type);
            Assert.AreEqual((UInt32)transaction["timestamp"], actual.Timestamp);
            Assert.AreEqual((string)transaction["senderPublicKey"], actual.SenderPublicKey);
            Assert.AreEqual((UInt64)transaction["fee"], actual.Fee);
            Assert.AreEqual((UInt64)transaction["amount"], actual.Amount);
            Assert.AreEqual((string)transaction["signature"], actual.Signature);
            Assert.AreEqual((string)transaction["id"], actual.Id);
            Assert.AreEqual((string)transaction["asset"]["delegate"]["username"], actual.Asset["delegate"]["username"]);
        }
Exemple #6
0
        public void Should_Deserialize_The_Transaction_With_A_Passphrase()
        {
            var fixture     = TestHelper.ReadTransactionFixture("transfer", "passphrase");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(1, actual.Version);
            Assert.AreEqual(30, actual.Network);
            Assert.AreEqual((byte)transaction["type"], actual.Type);
            Assert.AreEqual((UInt32)transaction["timestamp"], actual.Timestamp);
            Assert.AreEqual((string)transaction["senderPublicKey"], actual.SenderPublicKey);
            Assert.AreEqual((UInt64)transaction["fee"], actual.Fee);
            Assert.AreEqual((UInt64)transaction["amount"], actual.Amount);
            Assert.AreEqual(UInt32.MinValue, actual.Expiration);
            Assert.AreEqual((string)transaction["recipientId"], actual.RecipientId);
            Assert.AreEqual((string)transaction["signature"], actual.Signature);
            Assert.AreEqual((string)transaction["id"], actual.Id);
            Assert.IsTrue(actual.Verify());
        }
        public void Should_Deserialize_The_Transaction_With_A_Passphrase()
        {
            var fixture     = TestHelper.ReadTransactionFixture("multi_signature_registration", "passphrase");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(1, actual.Version);
            Assert.AreEqual(23, actual.Network);
            Assert.AreEqual((byte)transaction["type"], actual.Type);
            Assert.AreEqual((UInt32)transaction["timestamp"], actual.Timestamp);
            Assert.AreEqual((string)transaction["senderPublicKey"], actual.SenderPublicKey);
            Assert.AreEqual((UInt64)transaction["fee"], actual.Fee);
            Assert.AreEqual((UInt64)transaction["amount"], actual.Amount);
            Assert.AreEqual((string)transaction["signature"], actual.Signature);
            Assert.AreEqual((string)transaction["id"], actual.Id);
            Assert.AreEqual((byte)transaction["asset"]["multisignature"]["min"], actual.Asset["multisignature"]["min"]);
            Assert.AreEqual((byte)transaction["asset"]["multisignature"]["lifetime"], actual.Asset["multisignature"]["lifetime"]);

            CollectionAssert.AreEqual(transaction["asset"]["multisignature"]["keysgroup"].ToObject <List <string> >(), actual.Asset["multisignature"]["keysgroup"]);
        }
Exemple #8
0
        public void Should_Deserialize_The_Transaction_With_A_Passphrase()
        {
            var fixture     = TestHelper.ReadTransactionFixture("second_signature_registration", "second-passphrase");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(1, actual.Version);
            Assert.AreEqual(30, actual.Network);
            Assert.AreEqual((byte)transaction["type"], actual.Type);
            Assert.AreEqual((UInt32)transaction["timestamp"], actual.Timestamp);
            Assert.AreEqual((string)transaction["senderPublicKey"], actual.SenderPublicKey);
            Assert.AreEqual((UInt64)transaction["fee"], actual.Fee);
            Assert.AreEqual((UInt64)transaction["amount"], actual.Amount);
            Assert.AreEqual((string)transaction["signature"], actual.Signature);
            Assert.AreEqual((string)transaction["id"], actual.Id);
            Assert.AreEqual((string)transaction["asset"]["signature"]["publicKey"], actual.Asset["signature"]["publicKey"]);

            // special case as the type 1 transaction itself has no recipientId
            Assert.AreEqual(Address.FromPublicKey(PublicKey.FromHex(actual.SenderPublicKey)), actual.RecipientId);
        }
Exemple #9
0
        public void Should_Deserialize_The_Transaction_With_A_Second_Passphrase()
        {
            var fixture     = TestHelper.ReadTransactionFixture("vote", "second-passphrase");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(1, actual.Version);
            Assert.AreEqual(30, actual.Network);
            Assert.AreEqual((byte)transaction["type"], actual.Type);
            Assert.AreEqual((UInt32)transaction["timestamp"], actual.Timestamp);
            Assert.AreEqual((string)transaction["senderPublicKey"], actual.SenderPublicKey);
            Assert.AreEqual((UInt64)transaction["fee"], actual.Fee);
            Assert.AreEqual((UInt64)transaction["amount"], actual.Amount);
            Assert.AreEqual(UInt32.MinValue, actual.Expiration);
            Assert.AreEqual((string)transaction["recipientId"], actual.RecipientId);
            Assert.AreEqual((string)transaction["signature"], actual.Signature);
            Assert.AreEqual((string)transaction["signSignature"], actual.SignSignature);
            Assert.AreEqual((string)transaction["id"], actual.Id);

            CollectionAssert.AreEqual(actual.Asset["votes"], transaction["asset"]["votes"].ToObject <List <string> >());
        }
Exemple #10
0
        public void Should_Deserialize_The_Transaction_With_A_Passphrase_And_A_VendorField_Hex()
        {
            var fixture     = TestHelper.ReadTransactionFixture("transfer", "passphrase-with-vendor-field-hex");
            var transaction = fixture["data"];
            var actual      = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();

            Assert.AreEqual(1, actual.Version);
            Assert.AreEqual(30, actual.Network);
            Assert.AreEqual((byte)transaction["type"], actual.Type);
            Assert.AreEqual((UInt32)transaction["timestamp"], actual.Timestamp);
            Assert.AreEqual((string)transaction["senderPublicKey"], actual.SenderPublicKey);
            Assert.AreEqual((UInt64)transaction["fee"], actual.Fee);
            Assert.AreEqual((string)transaction["vendorFieldHex"], actual.VendorFieldHex);
            Assert.AreEqual((UInt64)transaction["amount"], actual.Amount);
            Assert.AreEqual(UInt32.MinValue, actual.Expiration);
            Assert.AreEqual((string)transaction["recipientId"], actual.RecipientId);
            Assert.AreEqual((string)transaction["signature"], actual.Signature);
            Assert.AreEqual((string)transaction["id"], actual.Id);

            Assert.AreEqual(Encoders.Hex.EncodeData(new Crypto.Transactions.Serializer(actual).Serialize()), fixture["serialized"]);
        }
        public void ToDictionary()
        {
            var fixture     = TestHelper.ReadTransactionFixture("transfer", "passphrase");
            var transaction = new Crypto.Transactions.Deserializer(fixture["serialized"]).Deserialize();
            var dictionary  = transaction.ToDictionary();

            Assert.AreEqual(dictionary["amount"], transaction.Amount);
            Assert.AreEqual(dictionary["asset"], transaction.Asset);
            Assert.AreEqual(dictionary["fee"], transaction.Fee);
            Assert.AreEqual(dictionary["id"], transaction.Id);
            Assert.AreEqual(dictionary["network"], transaction.Network);
            Assert.AreEqual(dictionary["recipientId"], transaction.RecipientId);
            Assert.AreEqual(dictionary["secondSignature"], transaction.SecondSignature);
            Assert.AreEqual(dictionary["senderPublicKey"], transaction.SenderPublicKey);
            Assert.AreEqual(dictionary["signature"], transaction.Signature);
            Assert.AreEqual(dictionary["signatures"], transaction.Signatures);
            Assert.AreEqual(dictionary["signSignature"], transaction.SignSignature);
            Assert.AreEqual(dictionary["timestamp"], transaction.Timestamp);
            Assert.AreEqual(dictionary["type"], transaction.Type);
            Assert.AreEqual(dictionary["vendorField"], transaction.VendorField);
            Assert.AreEqual(dictionary["version"], transaction.Version);
        }