|
@ -4,6 +4,8 @@ import ( |
|
|
"testing" |
|
|
"testing" |
|
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/account" |
|
|
"github.com/tendermint/tendermint/account" |
|
|
|
|
|
. "github.com/tendermint/tendermint/common" |
|
|
|
|
|
"github.com/tendermint/tendermint/config" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func TestSendTxSignable(t *testing.T) { |
|
|
func TestSendTxSignable(t *testing.T) { |
|
@ -33,9 +35,10 @@ func TestSendTxSignable(t *testing.T) { |
|
|
} |
|
|
} |
|
|
signBytes := account.SignBytes(sendTx) |
|
|
signBytes := account.SignBytes(sendTx) |
|
|
signStr := string(signBytes) |
|
|
signStr := string(signBytes) |
|
|
expected := `{"Network":"74656E6465726D696E745F746573746E657433","Tx":[1,{"Inputs":[{"Address":"696E70757431","Amount":12345,"Sequence":67890},{"Address":"696E70757432","Amount":111,"Sequence":222}],"Outputs":[{"Address":"6F757470757431","Amount":333},{"Address":"6F757470757432","Amount":444}]}]}` |
|
|
|
|
|
|
|
|
expected := Fmt(`{"Network":"%X","Tx":[1,{"Inputs":[{"Address":"696E70757431","Amount":12345,"Sequence":67890},{"Address":"696E70757432","Amount":111,"Sequence":222}],"Outputs":[{"Address":"6F757470757431","Amount":333},{"Address":"6F757470757432","Amount":444}]}]}`, |
|
|
|
|
|
config.App().GetString("Network")) |
|
|
if signStr != expected { |
|
|
if signStr != expected { |
|
|
t.Errorf("Got unexpected sign string for SendTx") |
|
|
|
|
|
|
|
|
t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -53,9 +56,10 @@ func TestCallTxSignable(t *testing.T) { |
|
|
} |
|
|
} |
|
|
signBytes := account.SignBytes(callTx) |
|
|
signBytes := account.SignBytes(callTx) |
|
|
signStr := string(signBytes) |
|
|
signStr := string(signBytes) |
|
|
expected := `{"Network":"74656E6465726D696E745F746573746E657433","Tx":[2,{"Address":"636F6E747261637431","Data":"6461746131","Fee":222,"GasLimit":111,"Input":{"Address":"696E70757431","Amount":12345,"Sequence":67890}}]}` |
|
|
|
|
|
|
|
|
expected := Fmt(`{"Network":"%X","Tx":[2,{"Address":"636F6E747261637431","Data":"6461746131","Fee":222,"GasLimit":111,"Input":{"Address":"696E70757431","Amount":12345,"Sequence":67890}}]}`, |
|
|
|
|
|
config.App().GetString("Network")) |
|
|
if signStr != expected { |
|
|
if signStr != expected { |
|
|
t.Errorf("Got unexpected sign string for CallTx") |
|
|
|
|
|
|
|
|
t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -88,7 +92,8 @@ func TestBondTxSignable(t *testing.T) { |
|
|
} |
|
|
} |
|
|
signBytes := account.SignBytes(bondTx) |
|
|
signBytes := account.SignBytes(bondTx) |
|
|
signStr := string(signBytes) |
|
|
signStr := string(signBytes) |
|
|
expected := `{"Network":"74656E6465726D696E745F746573746E657433","Tx":[17,{"Inputs":[{"Address":"696E70757431","Amount":12345,"Sequence":67890},{"Address":"696E70757432","Amount":111,"Sequence":222}],"PubKey":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"UnbondTo":[{"Address":"6F757470757431","Amount":333},{"Address":"6F757470757432","Amount":444}]}]}` |
|
|
|
|
|
|
|
|
expected := Fmt(`{"Network":"%X","Tx":[17,{"Inputs":[{"Address":"696E70757431","Amount":12345,"Sequence":67890},{"Address":"696E70757432","Amount":111,"Sequence":222}],"PubKey":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"UnbondTo":[{"Address":"6F757470757431","Amount":333},{"Address":"6F757470757432","Amount":444}]}]}`, |
|
|
|
|
|
config.App().GetString("Network")) |
|
|
if signStr != expected { |
|
|
if signStr != expected { |
|
|
t.Errorf("Got unexpected sign string for BondTx") |
|
|
t.Errorf("Got unexpected sign string for BondTx") |
|
|
} |
|
|
} |
|
@ -101,7 +106,8 @@ func TestUnbondTxSignable(t *testing.T) { |
|
|
} |
|
|
} |
|
|
signBytes := account.SignBytes(unbondTx) |
|
|
signBytes := account.SignBytes(unbondTx) |
|
|
signStr := string(signBytes) |
|
|
signStr := string(signBytes) |
|
|
expected := `{"Network":"74656E6465726D696E745F746573746E657433","Tx":[18,{"Address":"6164647265737331","Height":111}]}` |
|
|
|
|
|
|
|
|
expected := Fmt(`{"Network":"%X","Tx":[18,{"Address":"6164647265737331","Height":111}]}`, |
|
|
|
|
|
config.App().GetString("Network")) |
|
|
if signStr != expected { |
|
|
if signStr != expected { |
|
|
t.Errorf("Got unexpected sign string for UnbondTx") |
|
|
t.Errorf("Got unexpected sign string for UnbondTx") |
|
|
} |
|
|
} |
|
@ -114,7 +120,8 @@ func TestRebondTxSignable(t *testing.T) { |
|
|
} |
|
|
} |
|
|
signBytes := account.SignBytes(rebondTx) |
|
|
signBytes := account.SignBytes(rebondTx) |
|
|
signStr := string(signBytes) |
|
|
signStr := string(signBytes) |
|
|
expected := `{"Network":"74656E6465726D696E745F746573746E657433","Tx":[19,{"Address":"6164647265737331","Height":111}]}` |
|
|
|
|
|
|
|
|
expected := Fmt(`{"Network":"%X","Tx":[19,{"Address":"6164647265737331","Height":111}]}`, |
|
|
|
|
|
config.App().GetString("Network")) |
|
|
if signStr != expected { |
|
|
if signStr != expected { |
|
|
t.Errorf("Got unexpected sign string for RebondTx") |
|
|
t.Errorf("Got unexpected sign string for RebondTx") |
|
|
} |
|
|
} |
|
|