예제 #1
0
        private void FillRandomTx(Transaction tx)
        {
            var witnessOperationsManager     = new WitnessOperationsManager(Crypto.Default);
            var transactionOperationsManager = new TransactionOperationManager(Crypto.Default, this._serializer, witnessOperationsManager, new Mock <ITransactionRepository>().Object, new Mock <IAssetRepository>().Object, new TransactionContext());

            tx.Attributes = RandomTransactionAtrributes().ToArray();
            tx.Inputs     = RandomCoinReferences(_random.Next(1, 255)).ToArray();
            tx.Outputs    = RandomTransactionOutputs().ToArray();
            tx.Witness    = RandomWitness().ToArray();

            transactionOperationsManager.Sign(tx);
        }
예제 #2
0
        void EqualTx(Transaction original, params Transaction[] copies)
        {
            var witnessOperationsManager     = new WitnessOperationsManager(Crypto.Default);
            var transactionOperationsManager = new TransactionOperationManager(Crypto.Default, this._serializer, witnessOperationsManager, new Mock <ITransactionRepository>().Object, new Mock <IAssetRepository>().Object, new TransactionContext());

            foreach (var copy in copies)
            {
                Assert.AreEqual(original.GetType(), copy.GetType());

                Assert.AreEqual(original.Type, copy.Type);
                Assert.AreEqual(original.Version, copy.Version);

                CollectionAssert.AreEqual(original.Attributes, copy.Attributes);
                CollectionAssert.AreEqual(original.Inputs, copy.Inputs);
                CollectionAssert.AreEqual(original.Outputs, copy.Outputs);
                CollectionAssert.AreEqual(original.Witness, copy.Witness);

                // Recompute hash

                transactionOperationsManager.Sign(copy);

                Assert.AreEqual(original.Hash, copy.Hash);
            }
        }