public void PaymentSplitContractTest() { Account account = fluentClient.ConstructAccount(baseKeyPair); BaseKeyPair rec1 = BaseKeyPair.Generate(); BaseKeyPair rec2 = BaseKeyPair.Generate(); BaseKeyPair rec3 = BaseKeyPair.Generate(); //map(address, int) Dictionary <string, int> input = new Dictionary <string, int>(); input.Add(rec1.PublicKey, 40); input.Add(rec2.PublicKey, 40); input.Add(rec3.PublicKey, 20); decimal paymentValue = 1m.ToAettos(Unit.AE); string paymentSplitterSource = File.ReadAllText(Path.Combine(ResourcePath, "contracts", "PaymentSplitter.aes"), Encoding.UTF8); Contract contract = account.ConstructContract(paymentSplitterSource); ContractReturn depReturn = contract.MeasureAndDeploy(0, 0, Constants.BaseConstants.MINIMAL_GAS_PRICE, "init", input).WaitForFinish(TimeSpan.FromSeconds(30)); Assert.IsTrue(depReturn.Events.Any(a => a.Name == "AddingInitialRecipients")); ContractReturn callReturn = contract.MeasureAndCall("payAndSplit", Constants.BaseConstants.MINIMAL_GAS_PRICE, (ulong)paymentValue).WaitForFinish(TimeSpan.FromSeconds(30)); Assert.IsTrue(callReturn.Events.Any(a => a.Name == "PaymentReceivedAndSplitted")); Assert.AreEqual(new BigInteger(paymentValue * 0.4m), fluentClient.ConstructAccount(rec1).Balance); Assert.AreEqual(new BigInteger(paymentValue * 0.4m), fluentClient.ConstructAccount(rec2).Balance); Assert.AreEqual(new BigInteger(paymentValue * 0.2m), fluentClient.ConstructAccount(rec3).Balance); }
public void IdentityContractTest() { Account account = fluentClient.ConstructAccount(baseKeyPair); Contract contract = account.ConstructContract(TestConstants.TestContractSourceCode); Assert.AreEqual(TestConstants.TestContractByteCode, contract.ByteCode); ContractReturn ret = contract.Deploy(0, 0, 2000000000, 100000).WaitForFinish(TimeSpan.FromSeconds(30)); ContractReturn <int> re = contract.StaticCall <int>("main", 0, 42); Assert.AreEqual(re.ReturnValue, 42); }