예제 #1
0
        public void TestTxBuilder()
        {
            // Build the test Msg
            StdMsg message = new StdMsg(type: "cosmos-sdk/MsgSend",
                                        value: new Dictionary <String, Object>
            {
                { "from_address", "cosmos1huydeevpz37sd9snkgul6070mstupukw00xkw9" },
                { "to_address", "cosmos12lla7fg3hjd2zj6uvf4pqj7atx273klc487c5k" },
                { "amount", new List <StdCoin> {
                      new StdCoin(denom: "uatom", amount: "100")
                  } }
            });

            // Read the expected test msg string from Test Resources (C# like - This is different from Dart approach)
            String expectedStrMsg = TestResources.SendStdTx;

            // Build the Msg
            List <StdMsg> msgList = new List <StdMsg> {
                message
            };
            // Call the builder
            StdTx txMsg = TxBuilder.buildStdTx(msgList);
            // Get the  String
            String strMsg = txMsg.ToString();

            // Check it
            Assert.AreEqual(strMsg, expectedStrMsg);
        }
예제 #2
0
        public void TestJson()
        {
            StdTx                       origTx;
            StdSignature                origSignature;
            StdMsg                      origMsg;
            List <StdSignature>         tSignatures;
            List <StdMsg>               tMessages;
            StdMsg_test                 t;
            StdFee                      tFee;
            Dictionary <String, Object> origJson;
            String                      outString;

            origSignature = new StdSignature(publicKey: new StdPublicKey("PublicKeyType", "PublicKeyValue"), value: "PublicKeySample");
            tSignatures   = new List <StdSignature> {
                origSignature, origSignature
            };

            t         = new StdMsg_test();
            origMsg   = t.createMsg();
            tMessages = new List <StdMsg> {
                origMsg, origMsg
            };

            tFee = new StdFee(amount: new List <StdCoin> {
                new StdCoin(denom: "Coin1Denom", amount: "Coin1Amount"), new StdCoin(denom: "Coin2Denom", amount: "Coin2Amount")
            }, gas: "GasValue");

            origTx   = new StdTx(messages: tMessages, signatures: tSignatures, fee: tFee, memo: "StdMemoValue");
            origJson = origTx.toJson();

            // Here just for debugging
            outString = origTx.ToString();

            // USeless - the test just create the object...
            Assert.AreEqual(origTx, origTx);
        }