Ejemplo n.º 1
0
        public void STTransactionEntryDao_STTransactionEntry_Should_Be_Convertible()
        {
            var pubKeyBytes = new byte[30];

            new Random().NextBytes(pubKeyBytes);

            var original = new PublicEntry
            {
                Amount          = 8855274.ToUint256ByteString(),
                SenderAddress   = pubKeyBytes.ToByteString(),
                TransactionFees = UInt256.Zero.ToUint256ByteString(),
                Signature       = new Signature
                {
                    RawBytes = new byte[] { 0x0 }.ToByteString(),
                SigningContext = new SigningContext
                    {
                        NetworkType = NetworkType.Devnet, SignatureType = SignatureType.TransactionPublic
                    }
                },
                Timestamp = Timestamp.FromDateTime(DateTime.UtcNow)
            };

            var transactionEntryDao = original.ToDao <PublicEntry, PublicEntryDao>(_mapperProvider);

            transactionEntryDao.SenderAddress.Should().Be(pubKeyBytes.KeyToString());
            transactionEntryDao.Amount.Should().Be(8855274.ToString());

            var reconverted = transactionEntryDao.ToProtoBuff <PublicEntryDao, PublicEntry>(_mapperProvider);

            reconverted.TransactionFees.ToUInt256().Should().Be(UInt256.Zero);
            reconverted.Should().Be(original);
        }
Ejemplo n.º 2
0
        public void PublicEntryDao_Should_Be_The_Same_When_Converted()
        {
            var pubKeyBytes = new byte[30];

            new Random().NextBytes(pubKeyBytes);
            var original = new PublicEntry
            {
                Amount = new byte[] { 222, 11, 107, 58, 118, 64, 0, 0 }.ToByteString(),
                SenderAddress = pubKeyBytes.ToByteString(),
                Signature     = new Signature
                {
                    RawBytes = new byte[] { 0x0 }.ToByteString(),
                SigningContext = new SigningContext
                    {
                        NetworkType = NetworkType.Devnet, SignatureType = SignatureType.TransactionPublic
                    }
                }
            };

            var transactionEntryDao1 = original.ToDao <PublicEntry, PublicEntryDao>(_mapperProvider);
            var hashId1 = transactionEntryDao1.Id;

            var reconverted = transactionEntryDao1.ToProtoBuff <PublicEntryDao, PublicEntry>(_mapperProvider);

            var transactionEntryDao2 = reconverted.ToDao <PublicEntry, PublicEntryDao>(_mapperProvider);
            var hashId2 = transactionEntryDao2.Id;

            hashId1.Should().Be(hashId2);
        }