Skip to content

Commit

Permalink
services/horizon: Update state verifier tests to check the middle sig…
Browse files Browse the repository at this point in the history
…ner's sponsor (#3080)

Update state verifier integration test to check if it works correct if
the middle signer is sponsored.

To ensure that we check the 1:1 mapping correctly. The code was invalid
[1] in the past.

[1] #2945 (comment)
  • Loading branch information
bartekn authored Sep 30, 2020
1 parent f97e31e commit 47e9c16
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ func TestProtocol14StateVerifier(t *testing.T) {
AccountID: sponsored.Address(),
Sequence: 1,
}
signer := keypair.MustRandom()
signer1 := keypair.MustParseAddress("GAB3CVX6C2KCDZUUS4FIMP5Z2IUDTMKMRKADOFOCNOB437VCPS5DRG3Z")
signer2 := keypair.MustParseAddress("GBUERII77FW6Z7SPOIMFQQT63PMUQRWTIAARR3QVSXTRULNQSUQVIYRC")
signer3 := keypair.MustParseAddress("GCNLAKGPBL4H6CQRITHSDTJZ6RLTP3WY2OJZJN4EWKRSNM2A23CV6VD3")

// The operations below create a sponsorship sandwich, sponsoring an
// account, its trustlines, offers, data, and claimable balances.
// TODO multiple signers and a sponsor at non-first position
// Then 3 signers are created with the middle one sponsored.
master := itest.Master()
ops := []txnbuild.Operation{
&txnbuild.BeginSponsoringFutureReserves{
Expand All @@ -36,10 +38,6 @@ func TestProtocol14StateVerifier(t *testing.T) {
Destination: sponsored.Address(),
Amount: "100",
},
&txnbuild.CreateAccount{
Destination: signer.Address(),
Amount: "100",
},
&txnbuild.ChangeTrust{
SourceAccount: sponsoredSource,
Line: txnbuild.CreditAsset{"ABCD", master.Address()},
Expand All @@ -65,16 +63,36 @@ func TestProtocol14StateVerifier(t *testing.T) {
txnbuild.NewClaimant(keypair.MustRandom().Address(), nil),
},
},
&txnbuild.EndSponsoringFutureReserves{
SourceAccount: sponsoredSource,
},
&txnbuild.SetOptions{
SourceAccount: sponsoredSource,
Signer: &txnbuild.Signer{
Address: signer.Address(),
Address: signer1.Address(),
Weight: 3,
},
},
&txnbuild.BeginSponsoringFutureReserves{
SponsoredID: sponsored.Address(),
},
&txnbuild.SetOptions{
SourceAccount: sponsoredSource,
Signer: &txnbuild.Signer{
Address: signer2.Address(),
Weight: 3,
},
},
&txnbuild.EndSponsoringFutureReserves{
SourceAccount: sponsoredSource,
},
&txnbuild.SetOptions{
SourceAccount: sponsoredSource,
Signer: &txnbuild.Signer{
Address: signer3.Address(),
Weight: 3,
},
},
}
txResp, err := itest.SubmitMultiSigOperations(itest.MasterAccount(), []*keypair.Full{master, sponsored}, ops...)
assert.NoError(t, err)
Expand Down

0 comments on commit 47e9c16

Please sign in to comment.