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); }
// Method to create a msg public StdMsg createMsg() { StdMsg newMsg; newMsg = new StdMsg(type: "MessaggioTipo", value: new Dictionary <String, Object> { { "Msg1", "Primo messaggio di test" }, { "Msg2", "Secondo messaggio di test" } }); return(newMsg); }
private HttpResponseMessage CreateResponse <T>(T data) { var temp = new StdMsg <IResponseMessage>(_bodyConverter) { ContentType = ContentType.JSON, }; var t = new ResponseMessage <T>(); t.data = data; temp.Data = t; return(temp.CreateResponseMsg(System.Net.HttpStatusCode.OK)); }
private HttpResponseMessage CreateErrorResponse(string code, string msg) { var temp = new StdMsg <IResponseMessage>(_bodyConverter) { ContentType = ContentType.JSON, }; var t = new ErrorResponseMessage(); t.error_code = code; t.error_message = msg; temp.Data = t; return(temp.CreateResponseMsg(System.Net.HttpStatusCode.InternalServerError)); }
public async Task test_broadcastStdTx() { //This is the comparison class CompareLogic compareLogic = new CompareLogic(); NetworkInfo networkInfo = new NetworkInfo(bech32Hrp: "did:com:", lcdUrl: "http://localhost:1317"); //primo mnemonic String mnemonicString1 = "gorilla soldier device force cupboard transfer lake series cement another bachelor fatigue royal lens juice game sentence right invite trade perfect town heavy what"; List <String> mnemonic = new List <String>(mnemonicString1.Split(" ", StringSplitOptions.RemoveEmptyEntries)); //secondo mnemonic String mnemonicString2 = "daughter conduct slab puppy horn wrap bone road custom acoustic adjust target price trip unknown agent infant proof whip picnic exact hobby phone spin"; List <String> mnemonic2 = new List <String>(mnemonicString2.Split(" ", StringSplitOptions.RemoveEmptyEntries)); Wallet wallet = Wallet.derive(mnemonic, networkInfo); Wallet recipientWallet = Wallet.derive(mnemonic2, networkInfo); List <StdCoin> depositAmount = new List <StdCoin> { new StdCoin(denom: "ucommercio", amount: "10000") }; var dict = new Dictionary <string, object>(); dict.Add("from_address", wallet.bech32Address); dict.Add("to_address", recipientWallet.bech32Address); dict.Add("amount", depositAmount); StdMsg testmsg = new StdMsg("cosmos-sdk/MsgSend", dict); List <StdMsg> Listtestmsg = new List <StdMsg>(); Listtestmsg.Add(testmsg); StdFee fee = new StdFee(depositAmount, "200000"); //Invio try { var stdTx = TxBuilder.buildStdTx(Listtestmsg, "", fee); var signedStdTx = await TxSigner.signStdTx(wallet : wallet, stdTx : stdTx); var result = await TxSender.broadcastStdTx(wallet : wallet, stdTx : signedStdTx); if (result.success) { Console.WriteLine("Tx send successfully:\n$lcdUrl/txs/${result.hash}"); } else { Console.WriteLine("Tx error message:\n${result.error?.errorMessage}"); } } catch (Exception ex) { Console.WriteLine("Error while testing Sacco:\n$error"); } }