Skip to content

Commit

Permalink
xdr: update xdr definitions (#2494)
Browse files Browse the repository at this point in the history
The xdr source files match the following git commit in the stellar core repo:
stellar/stellar-core@b5dad7d
  • Loading branch information
tamirms committed Apr 20, 2020
1 parent 708ca21 commit 81e6559
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 190 deletions.
2 changes: 1 addition & 1 deletion network/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestHashTransaction(t *testing.T) {

feeBumpTx := xdr.FeeBumpTransaction{
Fee: 123456,
FeeSource: xdr.MustAddress("GCLOMB72ODBFUGK4E2BK7VMR3RNZ5WSTMEOGNA2YUVHFR3WMH2XBAB6H"),
FeeSource: xdr.MustMuxedAccountAddress("GCLOMB72ODBFUGK4E2BK7VMR3RNZ5WSTMEOGNA2YUVHFR3WMH2XBAB6H"),
InnerTx: xdr.FeeBumpTransactionInnerTx{
Type: xdr.EnvelopeTypeEnvelopeTypeTx,
V1: &xdr.TransactionV1Envelope{
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/db2/history/fee_bump_scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func FeeBumpScenario(tt *test.T, q *Q, successful bool) FeeBumpFixture {
Type: xdr.EnvelopeTypeEnvelopeTypeTxFeeBump,
FeeBump: &xdr.FeeBumpTransactionEnvelope{
Tx: xdr.FeeBumpTransaction{
FeeSource: xdr.AccountId{
Type: xdr.PublicKeyTypePublicKeyTypeEd25519,
FeeSource: xdr.MuxedAccount{
Type: xdr.CryptoKeyTypeKeyTypeEd25519,
Ed25519: &xdr.Uint256{2, 2, 2},
},
Fee: 776,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func transactionToMap(transaction io.LedgerTransaction, sequence uint32) (map[st
if transaction.Envelope.IsFeeBump() {
innerHash := transaction.Result.InnerHash()
m["inner_transaction_hash"] = hex.EncodeToString(innerHash[:])
feeAccount := transaction.Envelope.FeeBumpAccount()
feeAccount := transaction.Envelope.FeeBumpAccount().ToAccountId()
m["fee_account"] = feeAccount.Address()
m["new_max_fee"] = transaction.Envelope.FeeBumpFee()
m["inner_signatures"] = sqx.StringArray(signatures(transaction.Envelope.Signatures()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,47 @@ import (
)

func TestTransactionToMap_muxed(t *testing.T) {
muxed := xdr.MustMuxedAccountAddress("MCAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITKNOG")
innerSource := xdr.MuxedAccount{
Type: xdr.CryptoKeyTypeKeyTypeMuxedEd25519,
Med25519: &xdr.MuxedAccountMed25519{
Id: 1,
Ed25519: xdr.Uint256{3, 2, 1},
},
}
innerAccountID := innerSource.ToAccountId()
feeSource := xdr.MuxedAccount{
Type: xdr.CryptoKeyTypeKeyTypeMuxedEd25519,
Med25519: &xdr.MuxedAccountMed25519{
Id: 1,
Ed25519: xdr.Uint256{0, 1, 2},
},
}
feeSourceAccountID := feeSource.ToAccountId()
tx := io.LedgerTransaction{
Index: 1,
Envelope: xdr.TransactionEnvelope{
Type: xdr.EnvelopeTypeEnvelopeTypeTx,
V1: &xdr.TransactionV1Envelope{
Tx: xdr.Transaction{
SourceAccount: muxed,
Operations: []xdr.Operation{
{
SourceAccount: &muxed,
Body: xdr.OperationBody{
Type: xdr.OperationTypePayment,
PaymentOp: &xdr.PaymentOp{
Destination: muxed,
Asset: xdr.Asset{Type: xdr.AssetTypeAssetTypeNative},
Amount: 100,
Type: xdr.EnvelopeTypeEnvelopeTypeTxFeeBump,
FeeBump: &xdr.FeeBumpTransactionEnvelope{
Tx: xdr.FeeBumpTransaction{
FeeSource: feeSource,
Fee: 200,
InnerTx: xdr.FeeBumpTransactionInnerTx{
Type: xdr.EnvelopeTypeEnvelopeTypeTx,
V1: &xdr.TransactionV1Envelope{
Tx: xdr.Transaction{
SourceAccount: innerSource,
Operations: []xdr.Operation{
{
SourceAccount: &innerSource,
Body: xdr.OperationBody{
Type: xdr.OperationTypePayment,
PaymentOp: &xdr.PaymentOp{
Destination: innerSource,
Asset: xdr.Asset{Type: xdr.AssetTypeAssetTypeNative},
Amount: 100,
},
},
},
},
},
},
Expand All @@ -35,9 +59,12 @@ func TestTransactionToMap_muxed(t *testing.T) {
},
},
Result: xdr.TransactionResultPair{
TransactionHash: xdr.Hash{1, 2, 3},
Result: xdr.TransactionResult{
Result: xdr.TransactionResultResult{
Code: xdr.TransactionResultCodeTxFeeBumpInnerSuccess,
InnerResultPair: &xdr.InnerTransactionResultPair{
TransactionHash: xdr.Hash{3, 2, 1},
Result: xdr.InnerTransactionResult{
Result: xdr.InnerTransactionResultResult{
Results: &[]xdr.OperationResult{},
Expand All @@ -58,8 +85,12 @@ func TestTransactionToMap_muxed(t *testing.T) {
},
}
result, err := transactionToMap(tx, 20)
if assert.NoError(t, err) {
assert.Equal(t, "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ", result["account"])
}
assert.NoError(t, err)

assert.NotEqual(t, innerSource.Address(), result["account"])
assert.Equal(t, innerAccountID.Address(), result["account"])

assert.NotEqual(t, feeSource.Address(), result["fee_account"])
assert.Equal(t, feeSourceAccountID.Address(), result["fee_account"])

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func participantsForTransaction(
transaction.Envelope.SourceAccount().ToAccountId(),
}
if transaction.Envelope.IsFeeBump() {
participants = append(participants, transaction.Envelope.FeeBumpAccount())
participants = append(participants, transaction.Envelope.FeeBumpAccount().ToAccountId())
}

p, err := participantsForMeta(transaction.Meta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (s *ParticipantsProcessorTestSuiteLedger) TestFeeBumptransaction() {
feeBumpTx.Envelope.V1.Tx.SourceAccount = xdr.MustMuxedAccountAddress(s.addresses[0])
feeBumpTx.Envelope.FeeBump = &xdr.FeeBumpTransactionEnvelope{
Tx: xdr.FeeBumpTransaction{
FeeSource: xdr.MustAddress(s.addresses[1]),
FeeSource: xdr.MustMuxedAccountAddress(s.addresses[1]),
Fee: 100,
InnerTx: xdr.FeeBumpTransactionInnerTx{
Type: xdr.EnvelopeTypeEnvelopeTypeTx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestPopulateTransaction_TextMemo(t *testing.T) {
},
},
},
FeeSource: xdr.MustAddress("GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU"),
FeeSource: xdr.MustMuxedAccountAddress("GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU"),
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions xdr/Stellar-ledger.x
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ struct LedgerCloseMetaV0
union LedgerCloseMeta switch (int v)
{
case 0:
LedgerCloseMetaV0 v0;
LedgerCloseMetaV0 v0;
};

}
12 changes: 6 additions & 6 deletions xdr/Stellar-overlay.x
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ struct TopologyResponseBody

union SurveyResponseBody switch (SurveyMessageCommandType type)
{
case SURVEY_TOPOLOGY:
TopologyResponseBody topologyResponseBody;
case SURVEY_TOPOLOGY:
TopologyResponseBody topologyResponseBody;
};

union StellarMessage switch (MessageType type)
Expand Down Expand Up @@ -220,10 +220,10 @@ union AuthenticatedMessage switch (uint32 v)
{
case 0:
struct
{
uint64 sequence;
StellarMessage message;
HmacSha256Mac mac;
{
uint64 sequence;
StellarMessage message;
HmacSha256Mac mac;
} v0;
};
}
Loading

0 comments on commit 81e6559

Please sign in to comment.