@@ -48,7 +48,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
48
48
s .T ().Log ("setting up integration test suite" )
49
49
50
50
cfg := network .DefaultConfig ()
51
- cfg .NumValidators = 1
51
+ cfg .NumValidators = 2
52
52
53
53
s .cfg = cfg
54
54
s .network = network .New (s .T (), cfg )
@@ -1029,6 +1029,62 @@ func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk.
1029
1029
return res
1030
1030
}
1031
1031
1032
+ func (s * IntegrationTestSuite ) TestSignWithMultiSigners_AminoJSON () {
1033
+ val0 , val1 := s .network .Validators [0 ], s .network .Validators [1 ]
1034
+
1035
+ val0Coin := sdk .NewCoin (fmt .Sprintf ("%stoken" , val0 .Moniker ), sdk .NewInt (10 ))
1036
+ val1Coin := sdk .NewCoin (fmt .Sprintf ("%stoken" , val1 .Moniker ), sdk .NewInt (10 ))
1037
+
1038
+ _ , _ , addr1 := testdata .KeyTestPubAddr ()
1039
+
1040
+ // Creating a tx with 2 msgs from 2 signers: val0 and val1.
1041
+ // The validators sign with SIGN_MODE_LEGACY_AMINO_JSON by default.
1042
+ // Since we we amino, we don't need to pre-populate signer_infos.
1043
+ txBuilder := val0 .ClientCtx .TxConfig .NewTxBuilder ()
1044
+ txBuilder .SetMsgs (
1045
+ banktypes .NewMsgSend (val0 .Address , addr1 , sdk .NewCoins (val0Coin )),
1046
+ banktypes .NewMsgSend (val1 .Address , addr1 , sdk .NewCoins (val1Coin )),
1047
+ )
1048
+ txBuilder .SetFeeAmount (sdk .NewCoins (sdk .NewCoin (s .cfg .BondDenom , sdk .NewInt (10 ))))
1049
+ txBuilder .SetGasLimit (testdata .NewTestGasLimit ())
1050
+ s .Require ().Equal ([]sdk.AccAddress {val0 .Address , val1 .Address }, txBuilder .GetTx ().GetSigners ())
1051
+
1052
+ // Write the unsigned tx into a file.
1053
+ txJSON , err := val0 .ClientCtx .TxConfig .TxJSONEncoder ()(txBuilder .GetTx ())
1054
+ s .Require ().NoError (err )
1055
+ unsignedTxFile := testutil .WriteToNewTempFile (s .T (), string (txJSON ))
1056
+
1057
+ // Let val0 sign first the file with the unsignedTx.
1058
+ signedByVal0 , err := authtest .TxSignExec (val0 .ClientCtx , val0 .Address , unsignedTxFile .Name (), "--overwrite" )
1059
+ s .Require ().NoError (err )
1060
+ signedByVal0File := testutil .WriteToNewTempFile (s .T (), signedByVal0 .String ())
1061
+
1062
+ // Then let val1 sign the file with signedByVal0.
1063
+ val1AccNum , val1Seq , err := val0 .ClientCtx .AccountRetriever .GetAccountNumberSequence (val0 .ClientCtx , val1 .Address )
1064
+ s .Require ().NoError (err )
1065
+ signedTx , err := authtest .TxSignExec (
1066
+ val1 .ClientCtx , val1 .Address , signedByVal0File .Name (),
1067
+ "--offline" , fmt .Sprintf ("--account-number=%d" , val1AccNum ), fmt .Sprintf ("--sequence=%d" , val1Seq ),
1068
+ )
1069
+ s .Require ().NoError (err )
1070
+ signedTxFile := testutil .WriteToNewTempFile (s .T (), signedTx .String ())
1071
+
1072
+ // Now let's try to send this tx.
1073
+ res , err := authtest .TxBroadcastExec (val0 .ClientCtx , signedTxFile .Name (), fmt .Sprintf ("--%s=%s" , flags .FlagBroadcastMode , flags .BroadcastBlock ))
1074
+ s .Require ().NoError (err )
1075
+ var txRes sdk.TxResponse
1076
+ s .Require ().NoError (val0 .ClientCtx .JSONMarshaler .UnmarshalJSON (res .Bytes (), & txRes ))
1077
+ s .Require ().Equal (uint32 (0 ), txRes .Code )
1078
+
1079
+ // Make sure the addr1's balance got funded.
1080
+ queryResJSON , err := bankcli .QueryBalancesExec (val0 .ClientCtx , addr1 )
1081
+ s .Require ().NoError (err )
1082
+ var queryRes banktypes.QueryAllBalancesResponse
1083
+ err = val0 .ClientCtx .JSONMarshaler .UnmarshalJSON (queryResJSON .Bytes (), & queryRes )
1084
+ s .Require ().NoError (err )
1085
+ s .Require ().Equal (sdk .NewCoins (val0Coin , val1Coin ), queryRes .Balances )
1086
+ }
1087
+
1032
1088
func TestIntegrationTestSuite (t * testing.T ) {
1033
1089
suite .Run (t , new (IntegrationTestSuite ))
1034
1090
}
0 commit comments