Exemplo n.º 1
0
        public void TestRemoteDeployContractTx(bool localSign)
        {
            _remote = new Remote(ServerUrl, localSign);
            var resetEvent = new AutoResetEvent(false);
            DeployContractTxResponse result = null;

            _remote.Connect(_ =>
            {
                var options     = new DeployContractTxOptions();
                options.Account = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr";
                options.Amount  = 0.5;
                options.Payload = "result={}; function Init(t) result=scGetAccountInfo(t) return result end; function foo(t) a={} result=scGetAccountInfo(t) return result end;";
                options.Params  = new[] { "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr" };
                var tx          = _remote.DeployContractTx(options);
                tx.SetSecret("snhevp2qBEyPf3n8ZRDMuZGSa3BZ5");
                tx.AddMemo("Unit Test DeployContract at " + DateTime.Now.ToString());
                tx.Submit(r =>
                {
                    result = r.Result;
                    resetEvent.Set();
                });
            });

            Assert.IsTrue(resetEvent.WaitOne(DeferredWaitingTime));
            Assert.IsNotNull(result);
            Assert.AreEqual("tecNO_DST_INSUF_SWT", result.EngineResult);
        }
Exemplo n.º 2
0
        public void TestSignDeployContractTx()
        {
            var remote = new Remote("");

            remote.SetMockServer(new MockServer(remote, "RequestAccountInfo.json"));

            var    deferred = new Task(() => { });
            string blob     = null;
            var    options  = new DeployContractTxOptions();

            options.Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1";
            options.Amount  = 30;
            options.Payload = "result={}; function Init(t) result=scGetAccountInfo(t) return result end; function foo(t) a={} result=scGetAccountInfo(t) return result end;";
            options.Params  = new[] { "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr" };
            var tx = remote.DeployContractTx(options);

            tx.Data.TxnSignature = "3045022100CC48021620B52E3F40F74BA45B3C89089C4580154EAF1027FEED92E6D76705AA0220069112B3017B327245E4B1258A83D7DF8737EFB83716617FDB2337E9CC6490CB";
            tx.SetSecret("ssGkkAMnKCBkhGVQd9CNzSQv5zdNi");
            tx.AddMemo("Test deploy contract.");
            tx.Sign(r =>
            {
                blob = r.Result;
                deferred.Start();
            });

            Assert.IsTrue(deferred.Wait(DeferredWaitingTime * 10000));
            Assert.AreEqual("12001E22000000002400000005202400000000614000000001C9C380684000000000002710732102EA9C744CB32386A12B4E85A2E4A7844B3952528F700C1031DCBCD1DAC07ECD1F74473045022100CC48021620B52E3F40F74BA45B3C89089C4580154EAF1027FEED92E6D76705AA0220069112B3017B327245E4B1258A83D7DF8737EFB83716617FDB2337E9CC6490CB7F8C726573756C743D7B7D3B2066756E6374696F6E20496E697428742920726573756C743D73634765744163636F756E74496E666F2874292072657475726E20726573756C7420656E643B2066756E6374696F6E20666F6F28742920613D7B7D20726573756C743D73634765744163636F756E74496E666F2874292072657475726E20726573756C7420656E643B811460B1227191135B3B16CB1D74F2509BD5C5DF985BF9EA7D1554657374206465706C6F7920636F6E74726163742EE1F1FAEB7012226A4D773378726B5832795377645169456F72796D7975544C55535361383577765372E1F1", blob);
        }
Exemplo n.º 3
0
        private void InitDeployContractTxOptions()
        {
            var options = new DeployContractTxOptions();

            options.Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1";
            options.Amount  = 30;
            options.Payload = "result={}; function Init(t) result=scGetAccountInfo(t) return result end; function foo(t) a={} result=scGetAccountInfo(t) return result end;";
            options.Params  = new string[] { "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1" };
            pgDeployContractTxOptions.SelectedObject = options;

            var settings = new TxSettings();

            settings.Secret  = "ssGkkAMnKCBkhGVQd9CNzSQv5zdNi";
            settings.SendMax = new Amount();
            pgDeployContractTxSettings.SelectedObject = settings;
        }
Exemplo n.º 4
0
        public void TestDeployContractTxResponse()
        {
            var remote = new Remote("");

            remote.SetMockServer(new MockServer(remote, "DeployContractTx.json"));

            MessageResult <DeployContractTxResponse> response = null;
            var deferred = new Task(() => { });
            var options  = new DeployContractTxOptions();

            options.Account = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr";
            options.Payload = "...";
            options.Amount  = 30;
            remote.DeployContractTx(options).Submit(r =>
            {
                response = r;
                deferred.Start();
            });

            Assert.IsTrue(deferred.Wait(DeferredWaitingTime));

            Assert.IsNotNull(response);
            var result = response.Result;

            Assert.IsNotNull(result);

            Assert.AreEqual("tesSUCCESS", result.EngineResult);
            var txJson = result.TxJson;

            Assert.IsNotNull(txJson);
            Assert.AreEqual("jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", txJson.Account);
            Assert.AreEqual("jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", txJson.Args[0].Arg.Parameter);
            Assert.AreEqual("haha", txJson.Memos[0].Memo.MemoData);
            Assert.AreEqual(0, txJson.Method);
            Assert.AreEqual(new Amount {
                Currency = "SWT", Issuer = "", Value = "30"
            }, txJson.Amount);
            Assert.AreEqual(TransactionType.ConfigContract, txJson.TransactionType);
        }