Skip to content

Commit

Permalink
Compare balanceID as HEX. (stellar#3004)
Browse files Browse the repository at this point in the history
  • Loading branch information
abuiles authored Sep 15, 2020
1 parent 693b701 commit 4c15c21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,12 @@ func (e *effectsWrapper) addClaimClaimableBalanceEffects() error {

if change.Pre != nil && change.Post == nil {
cBalance = change.Pre.Data.MustClaimableBalance()
if cBalance.BalanceId == op.BalanceId {
preBalanceID, err := xdr.MarshalHex(cBalance.BalanceId)
if err != nil {
return fmt.Errorf("Invalid balanceId in meta changes for op: %d", e.operation.index)
}

if preBalanceID == balanceID {
found = true
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1894,9 +1894,11 @@ type ClaimClaimableBalanceEffectsTestSuite struct {
}

func (s *ClaimClaimableBalanceEffectsTestSuite) SetupTest() {
var balanceIDOp1, balanceIDOp2 xdr.ClaimableBalanceId
var balanceIDOp1, balanceIDOp1Meta, balanceIDOp2, balanceIDOp2Meta xdr.ClaimableBalanceId
xdr.SafeUnmarshalBase64("AAAAANoNV9p9SFDn/BDSqdDrxzH3r7QFdMAzlbF9SRSbkfW+", &balanceIDOp1)
xdr.SafeUnmarshalBase64("AAAAANoNV9p9SFDn/BDSqdDrxzH3r7QFdMAzlbF9SRSbkfW+", &balanceIDOp1Meta)
xdr.SafeUnmarshalBase64("AAAAALHcX0PDa9UefSAzitC6vQOUr802phH8OF2ahLzg6j1D", &balanceIDOp2)
xdr.SafeUnmarshalBase64("AAAAALHcX0PDa9UefSAzitC6vQOUr802phH8OF2ahLzg6j1D", &balanceIDOp2Meta)

aid := xdr.MustAddress("GD5OVB6FKDV7P7SOJ5UB2BPLBL4XGSHPYHINR5355SY3RSXLT2BZWAKY")
claimant1 := aid.ToMuxedAccount()
Expand Down Expand Up @@ -1973,7 +1975,7 @@ func (s *ClaimClaimableBalanceEffectsTestSuite) SetupTest() {
Data: xdr.LedgerEntryData{
Type: xdr.LedgerEntryTypeClaimableBalance,
ClaimableBalance: &xdr.ClaimableBalanceEntry{
BalanceId: balanceIDOp1,
BalanceId: balanceIDOp1Meta,
Amount: xdr.Int64(100000000),
Asset: xdr.MustNewNativeAsset(),
Claimants: []xdr.Claimant{
Expand All @@ -1997,7 +1999,7 @@ func (s *ClaimClaimableBalanceEffectsTestSuite) SetupTest() {
Removed: &xdr.LedgerKey{
Type: xdr.LedgerEntryTypeClaimableBalance,
ClaimableBalance: &xdr.LedgerKeyClaimableBalance{
BalanceId: balanceIDOp1,
BalanceId: balanceIDOp1Meta,
},
},
},
Expand All @@ -2012,7 +2014,7 @@ func (s *ClaimClaimableBalanceEffectsTestSuite) SetupTest() {
Data: xdr.LedgerEntryData{
Type: xdr.LedgerEntryTypeClaimableBalance,
ClaimableBalance: &xdr.ClaimableBalanceEntry{
BalanceId: balanceIDOp2,
BalanceId: balanceIDOp2Meta,
Amount: xdr.Int64(200000000),
Asset: xdr.MustNewCreditAsset("USD", "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD"),
Claimants: []xdr.Claimant{
Expand Down Expand Up @@ -2044,7 +2046,7 @@ func (s *ClaimClaimableBalanceEffectsTestSuite) SetupTest() {
Removed: &xdr.LedgerKey{
Type: xdr.LedgerEntryTypeClaimableBalance,
ClaimableBalance: &xdr.LedgerKeyClaimableBalance{
BalanceId: balanceIDOp2,
BalanceId: balanceIDOp2Meta,
},
},
},
Expand Down

0 comments on commit 4c15c21

Please sign in to comment.