From 9013d603fff8ded9c2697da9243197b74953832b Mon Sep 17 00:00:00 2001 From: Cayod Date: Tue, 26 Sep 2023 19:31:27 -0300 Subject: [PATCH 1/3] create export-tx --- cmd/export_tx.go | 83 ++++++++++++++++++++++++++++++++++++ internal/transform/schema.go | 10 +++++ internal/transform/tx.go | 58 +++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 cmd/export_tx.go create mode 100644 internal/transform/tx.go diff --git a/cmd/export_tx.go b/cmd/export_tx.go new file mode 100644 index 00000000..374f37c9 --- /dev/null +++ b/cmd/export_tx.go @@ -0,0 +1,83 @@ +package cmd + +import ( + "fmt" + + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "github.com/stellar/stellar-etl/internal/input" + "github.com/stellar/stellar-etl/internal/transform" + "github.com/stellar/stellar-etl/internal/utils" +) + +var txCmd = &cobra.Command{ + Use: "export_tx", + Short: "Exports the tx transaction data over a specified range.", + Long: `Exports the tx transaction data over a specified range to an output file.`, + Run: func(cmd *cobra.Command, args []string) { + cmdLogger.SetLevel(logrus.InfoLevel) + endNum, strictExport, isTest, isFuture, extra := utils.MustCommonFlags(cmd.Flags(), cmdLogger) + cmdLogger.StrictExport = strictExport + startNum, path, limit := utils.MustArchiveFlags(cmd.Flags(), cmdLogger) + gcsBucket, gcpCredentials := utils.MustGcsFlags(cmd.Flags(), cmdLogger) + env := utils.GetEnvironmentDetails(isTest, isFuture) + + tx, err := input.GetTransactions(startNum, endNum, limit, env) + if err != nil { + cmdLogger.Fatal("could not read tx: ", err) + } + + outFile := mustOutFile(path) + numFailures := 0 + totalNumBytes := 0 + for _, transformInput := range tx { + transformed, err := transform.TransformTx(transformInput.Transaction, transformInput.LedgerHistory) + if err != nil { + ledgerSeq := transformInput.LedgerHistory.Header.LedgerSeq + cmdLogger.LogError(fmt.Errorf("could not transform tx transaction %d in ledger %d: ", transformInput.Transaction.Index, ledgerSeq)) + numFailures += 1 + continue + } + + numBytes, err := exportEntry(transformed, outFile, extra) + if err != nil { + cmdLogger.LogError(fmt.Errorf("could not export transaction: %v", err)) + numFailures += 1 + continue + } + totalNumBytes += numBytes + } + + outFile.Close() + cmdLogger.Info("Number of bytes written: ", totalNumBytes) + + printTransformStats(len(tx), numFailures) + + maybeUpload(gcpCredentials, gcsBucket, path) + }, +} + +func init() { + rootCmd.AddCommand(txCmd) + utils.AddCommonFlags(txCmd.Flags()) + utils.AddArchiveFlags("tx", txCmd.Flags()) + utils.AddGcsFlags(txCmd.Flags()) + txCmd.MarkFlagRequired("end-ledger") + + /* + Current flags: + start-ledger: the ledger sequence number for the beginning of the export period + end-ledger: the ledger sequence number for the end of the export range (*required) + + limit: maximum number of tx to export + TODO: measure a good default value that ensures all tx within a 5 minute period will be exported with a single call + The current max_tx_set_size is 1000 and there are 60 new ledgers in a 5 minute period: + 1000*60 = 60000 + + output-file: filename of the output file + + TODO: implement extra flags if possible + serialize-method: the method for serialization of the output data (JSON, XDR, etc) + start and end time as a replacement for start and end sequence numbers + */ +} diff --git a/internal/transform/schema.go b/internal/transform/schema.go index 7713b188..e544294c 100644 --- a/internal/transform/schema.go +++ b/internal/transform/schema.go @@ -66,6 +66,16 @@ type TransactionOutput struct { SorobanResourcesWriteBytes uint32 `json:"soroban_resources_write_bytes"` } +type TxOutput struct { + LedgerSequence uint32 `json:"ledger_sequence"` + TxEnvelope string `json:"tx_envelope"` + TxResult string `json:"tx_result"` + TxMeta string `json:"tx_meta"` + TxFeeMeta string `json:"tx_fee_meta"` + TxLedgerHistory string `json:"tx_ledger_history"` + ClosedAt time.Time `json:"closed_at"` +} + // AccountOutput is a representation of an account that aligns with the BigQuery table accounts type AccountOutput struct { AccountID string `json:"account_id"` // account address diff --git a/internal/transform/tx.go b/internal/transform/tx.go new file mode 100644 index 00000000..3adda449 --- /dev/null +++ b/internal/transform/tx.go @@ -0,0 +1,58 @@ +package transform + +import ( + "fmt" + + "github.com/stellar/stellar-etl/internal/utils" + + "github.com/stellar/go/ingest" + "github.com/stellar/go/xdr" +) + +// TransformTransaction converts a transaction from the history archive ingestion system into a form suitable for BigQuery +func TransformTx(transaction ingest.LedgerTransaction, lhe xdr.LedgerHeaderHistoryEntry) (TxOutput, error) { + ledgerHeader := lhe.Header + outputLedgerSequence := uint32(ledgerHeader.LedgerSeq) + + outputTxEnvelope, err := xdr.MarshalBase64(transaction.Envelope) + if err != nil { + return TxOutput{}, err + } + + outputTxResult, err := xdr.MarshalBase64(&transaction.Result) + if err != nil { + return TxOutput{}, err + } + + outputTxMeta, err := xdr.MarshalBase64(transaction.UnsafeMeta) + if err != nil { + return TxOutput{}, err + } + + outputTxFeeMeta, err := xdr.MarshalBase64(transaction.FeeChanges) + if err != nil { + return TxOutput{}, err + } + + outputTxLedgerHistory, err := xdr.MarshalBase64(lhe) + if err != nil { + return TxOutput{}, err + } + + outputCloseTime, err := utils.TimePointToUTCTimeStamp(ledgerHeader.ScpValue.CloseTime) + if err != nil { + return TxOutput{}, fmt.Errorf("could not convert close time to UTC timestamp: %v", err) + } + + transformedTx := TxOutput{ + LedgerSequence: outputLedgerSequence, + TxEnvelope: outputTxEnvelope, + TxResult: outputTxResult, + TxMeta: outputTxMeta, + TxFeeMeta: outputTxFeeMeta, + TxLedgerHistory: outputTxLedgerHistory, + ClosedAt: outputCloseTime, + } + + return transformedTx, nil +} From ffa32ba07619f23544659c132cb3b70627b06dfc Mon Sep 17 00:00:00 2001 From: Cayod Date: Mon, 2 Oct 2023 11:14:04 -0300 Subject: [PATCH 2/3] create tx_test --- internal/transform/tx_test.go | 302 ++++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 internal/transform/tx_test.go diff --git a/internal/transform/tx_test.go b/internal/transform/tx_test.go new file mode 100644 index 00000000..7e489021 --- /dev/null +++ b/internal/transform/tx_test.go @@ -0,0 +1,302 @@ +package transform + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/stellar/go/ingest" + "github.com/stellar/go/xdr" +) + +func TestTransformTx(t *testing.T) { + type inputStruct struct { + transaction ingest.LedgerTransaction + historyHeader xdr.LedgerHeaderHistoryEntry + } + type transformTest struct { + input inputStruct + wantOutput TxOutput + wantErr error + } + + hardCodedTx, hardCodedLedgerHeader, err := makeTxTestInput() + assert.NoError(t, err) + hardCodedOutput, err := makeTxTestOutput() + assert.NoError(t, err) + + tests := []transformTest{} + + for i := range hardCodedTx { + tests = append(tests, transformTest{ + input: inputStruct{hardCodedTx[i], hardCodedLedgerHeader[i]}, + wantOutput: hardCodedOutput[i], + wantErr: nil, + }) + } + + for _, test := range tests { + actualOutput, actualError := TransformTx(test.input.transaction, test.input.historyHeader) + assert.Equal(t, test.wantErr, actualError) + assert.Equal(t, test.wantOutput, actualOutput) + } +} + +func makeTxTestOutput() (output []TxOutput, err error) { + output = []TxOutput{ + TxOutput{ + TxEnvelope: "AAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAABX5ABjydzAABBtwAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", + TxResult: "qH/vXusmAmnDgPLeRWqtcrWbsxWqrHd4YEVuCdrAuvsAAAAAAAABLP////8AAAABAAAAAAAAAAAAAAAAAAAAAA==", + TxMeta: "AAAAAQAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAA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edAt: time.Date(2020, time.July, 9, 5, 28, 42, 0, time.UTC), + }, + } + return +} +func makeTxTestInput() (transaction []ingest.LedgerTransaction, historyHeader []xdr.LedgerHeaderHistoryEntry, err error) { + hardCodedMemoText := "HL5aCgozQHIW7sSc5XdcfmR" + hardCodedTransactionHash := xdr.Hash([32]byte{0xa8, 0x7f, 0xef, 0x5e, 0xeb, 0x26, 0x2, 0x69, 0xc3, 0x80, 0xf2, 0xde, 0x45, 0x6a, 0xad, 0x72, 0xb5, 0x9b, 0xb3, 0x15, 0xaa, 0xac, 0x77, 0x78, 0x60, 0x45, 0x6e, 0x9, 0xda, 0xc0, 0xba, 0xfb}) + genericResultResults := &[]xdr.OperationResult{ + xdr.OperationResult{ + Tr: &xdr.OperationResultTr{ + Type: xdr.OperationTypeCreateAccount, + CreateAccountResult: &xdr.CreateAccountResult{ + Code: 0, + }, + }, + }, + } + hardCodedMeta := xdr.TransactionMeta{ + V: 1, + V1: genericTxMeta, + } + + source := xdr.MuxedAccount{ + Type: xdr.CryptoKeyTypeKeyTypeEd25519, + Ed25519: &xdr.Uint256{3, 2, 1}, + } + destination := xdr.MuxedAccount{ + Type: xdr.CryptoKeyTypeKeyTypeEd25519, + Ed25519: &xdr.Uint256{1, 2, 3}, + } + signerKey := xdr.SignerKey{ + Type: xdr.SignerKeyTypeSignerKeyTypeEd25519, + Ed25519: source.Ed25519, + } + transaction = []ingest.LedgerTransaction{ + ingest.LedgerTransaction{ + Index: 1, + UnsafeMeta: hardCodedMeta, + Envelope: xdr.TransactionEnvelope{ + Type: xdr.EnvelopeTypeEnvelopeTypeTx, + V1: &xdr.TransactionV1Envelope{ + Tx: xdr.Transaction{ + SourceAccount: testAccount1, + SeqNum: 112351890582290871, + Memo: xdr.Memo{ + Type: xdr.MemoTypeMemoText, + Text: &hardCodedMemoText, + }, + Fee: 90000, + Cond: xdr.Preconditions{ + Type: xdr.PreconditionTypePrecondTime, + TimeBounds: &xdr.TimeBounds{ + MinTime: 0, + MaxTime: 1594272628, + }, + }, + Operations: []xdr.Operation{ + xdr.Operation{ + SourceAccount: &testAccount2, + Body: xdr.OperationBody{ + Type: xdr.OperationTypePathPaymentStrictReceive, + PathPaymentStrictReceiveOp: &xdr.PathPaymentStrictReceiveOp{ + Destination: destination, + }, + }, + }, + }, + }, + }, + }, + Result: xdr.TransactionResultPair{ + TransactionHash: hardCodedTransactionHash, + Result: xdr.TransactionResult{ + FeeCharged: 300, + Result: xdr.TransactionResultResult{ + Code: xdr.TransactionResultCodeTxFailed, + Results: genericResultResults, + }, + }, + }, + }, + ingest.LedgerTransaction{ + Index: 1, + UnsafeMeta: hardCodedMeta, + Envelope: xdr.TransactionEnvelope{ + Type: xdr.EnvelopeTypeEnvelopeTypeTxFeeBump, + FeeBump: &xdr.FeeBumpTransactionEnvelope{ + Tx: xdr.FeeBumpTransaction{ + FeeSource: testAccount3, + Fee: 7200, + InnerTx: xdr.FeeBumpTransactionInnerTx{ + Type: xdr.EnvelopeTypeEnvelopeTypeTx, + V1: &xdr.TransactionV1Envelope{ + Tx: xdr.Transaction{ + SourceAccount: testAccount1, + SeqNum: 150015399398735997, + Memo: xdr.Memo{ + Type: xdr.MemoTypeMemoText, + Text: &hardCodedMemoText, + }, + Cond: xdr.Preconditions{ + Type: xdr.PreconditionTypePrecondTime, + TimeBounds: &xdr.TimeBounds{ + MinTime: 0, + MaxTime: 1594272628, + }, + }, + Operations: []xdr.Operation{ + xdr.Operation{ + SourceAccount: &testAccount2, + Body: xdr.OperationBody{ + Type: xdr.OperationTypePathPaymentStrictReceive, + PathPaymentStrictReceiveOp: &xdr.PathPaymentStrictReceiveOp{ + Destination: destination, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + Result: xdr.TransactionResultPair{ + TransactionHash: hardCodedTransactionHash, + Result: xdr.TransactionResult{ + FeeCharged: 300, + Result: xdr.TransactionResultResult{ + Code: xdr.TransactionResultCodeTxFeeBumpInnerSuccess, + InnerResultPair: &xdr.InnerTransactionResultPair{ + TransactionHash: hardCodedTransactionHash, + Result: xdr.InnerTransactionResult{ + FeeCharged: 100, + Result: xdr.InnerTransactionResultResult{ + Code: xdr.TransactionResultCodeTxSuccess, + Results: &[]xdr.OperationResult{ + xdr.OperationResult{ + Tr: &xdr.OperationResultTr{ + CreateAccountResult: &xdr.CreateAccountResult{}, + }, + }, + }, + }, + }, + }, + Results: &[]xdr.OperationResult{ + xdr.OperationResult{}, + }, + }, + }, + }, + }, + ingest.LedgerTransaction{ + Index: 1, + UnsafeMeta: hardCodedMeta, + Envelope: xdr.TransactionEnvelope{ + Type: xdr.EnvelopeTypeEnvelopeTypeTx, + V1: &xdr.TransactionV1Envelope{ + Tx: xdr.Transaction{ + SourceAccount: testAccount2, + SeqNum: 118426953012574851, + Memo: xdr.Memo{ + Type: xdr.MemoTypeMemoText, + Text: &hardCodedMemoText, + }, + Fee: 100, + Cond: xdr.Preconditions{ + Type: xdr.PreconditionTypePrecondV2, + V2: &xdr.PreconditionsV2{ + TimeBounds: &xdr.TimeBounds{ + MinTime: 0, + MaxTime: 1594272628, + }, + LedgerBounds: &xdr.LedgerBounds{ + MinLedger: 5, + MaxLedger: 10, + }, + ExtraSigners: []xdr.SignerKey{signerKey}, + }, + }, + Operations: []xdr.Operation{ + xdr.Operation{ + SourceAccount: &testAccount4, + Body: xdr.OperationBody{ + Type: xdr.OperationTypePathPaymentStrictReceive, + PathPaymentStrictReceiveOp: &xdr.PathPaymentStrictReceiveOp{ + Destination: destination, + }, + }, + }, + }, + }, + }, + }, + Result: xdr.TransactionResultPair{ + TransactionHash: hardCodedTransactionHash, + Result: xdr.TransactionResult{ + FeeCharged: 100, + Result: xdr.TransactionResultResult{ + Code: xdr.TransactionResultCodeTxFailed, + Results: genericResultResults, + }, + }, + }, + }, + } + historyHeader = []xdr.LedgerHeaderHistoryEntry{ + xdr.LedgerHeaderHistoryEntry{ + Header: xdr.LedgerHeader{ + LedgerSeq: 30521816, + ScpValue: xdr.StellarValue{CloseTime: 1594272522}, + }, + }, + xdr.LedgerHeaderHistoryEntry{ + Header: xdr.LedgerHeader{ + LedgerSeq: 30521817, + ScpValue: xdr.StellarValue{CloseTime: 1594272522}, + }, + }, + xdr.LedgerHeaderHistoryEntry{ + Header: xdr.LedgerHeader{ + LedgerSeq: 30521818, + ScpValue: xdr.StellarValue{CloseTime: 1594272522}, + }, + }, + } + return +} From 6215f975ee1c79f250197cae1a7363d404471c75 Mon Sep 17 00:00:00 2001 From: Cayod Date: Wed, 11 Oct 2023 15:58:53 -0300 Subject: [PATCH 3/3] change export_tx to export_ledger_transaction --- ...ort_tx.go => export_ledger_transaction.go} | 36 +++++++++---------- .../{tx.go => ledger_transaction.go} | 18 +++++----- ...{tx_test.go => ledger_transaction_test.go} | 24 ++++++------- internal/transform/schema.go | 2 +- 4 files changed, 40 insertions(+), 40 deletions(-) rename cmd/{export_tx.go => export_ledger_transaction.go} (55%) rename internal/transform/{tx.go => ledger_transaction.go} (67%) rename internal/transform/{tx_test.go => ledger_transaction_test.go} (94%) diff --git a/cmd/export_tx.go b/cmd/export_ledger_transaction.go similarity index 55% rename from cmd/export_tx.go rename to cmd/export_ledger_transaction.go index 374f37c9..8e623604 100644 --- a/cmd/export_tx.go +++ b/cmd/export_ledger_transaction.go @@ -10,10 +10,10 @@ import ( "github.com/stellar/stellar-etl/internal/utils" ) -var txCmd = &cobra.Command{ - Use: "export_tx", - Short: "Exports the tx transaction data over a specified range.", - Long: `Exports the tx transaction data over a specified range to an output file.`, +var ledgerTransactionCmd = &cobra.Command{ + Use: "export_ledger_transaction", + Short: "Exports the ledger_transaction transaction data over a specified range.", + Long: `Exports the ledger_transaction transaction data over a specified range to an output file.`, Run: func(cmd *cobra.Command, args []string) { cmdLogger.SetLevel(logrus.InfoLevel) endNum, strictExport, isTest, isFuture, extra := utils.MustCommonFlags(cmd.Flags(), cmdLogger) @@ -22,19 +22,19 @@ var txCmd = &cobra.Command{ gcsBucket, gcpCredentials := utils.MustGcsFlags(cmd.Flags(), cmdLogger) env := utils.GetEnvironmentDetails(isTest, isFuture) - tx, err := input.GetTransactions(startNum, endNum, limit, env) + ledgerTransaction, err := input.GetTransactions(startNum, endNum, limit, env) if err != nil { - cmdLogger.Fatal("could not read tx: ", err) + cmdLogger.Fatal("could not read ledger_transaction: ", err) } outFile := mustOutFile(path) numFailures := 0 totalNumBytes := 0 - for _, transformInput := range tx { - transformed, err := transform.TransformTx(transformInput.Transaction, transformInput.LedgerHistory) + for _, transformInput := range ledgerTransaction { + transformed, err := transform.TransformLedgerTransaction(transformInput.Transaction, transformInput.LedgerHistory) if err != nil { ledgerSeq := transformInput.LedgerHistory.Header.LedgerSeq - cmdLogger.LogError(fmt.Errorf("could not transform tx transaction %d in ledger %d: ", transformInput.Transaction.Index, ledgerSeq)) + cmdLogger.LogError(fmt.Errorf("could not transform ledger_transaction transaction %d in ledger %d: ", transformInput.Transaction.Index, ledgerSeq)) numFailures += 1 continue } @@ -51,27 +51,27 @@ var txCmd = &cobra.Command{ outFile.Close() cmdLogger.Info("Number of bytes written: ", totalNumBytes) - printTransformStats(len(tx), numFailures) + printTransformStats(len(ledgerTransaction), numFailures) maybeUpload(gcpCredentials, gcsBucket, path) }, } func init() { - rootCmd.AddCommand(txCmd) - utils.AddCommonFlags(txCmd.Flags()) - utils.AddArchiveFlags("tx", txCmd.Flags()) - utils.AddGcsFlags(txCmd.Flags()) - txCmd.MarkFlagRequired("end-ledger") + rootCmd.AddCommand(ledgerTransactionCmd) + utils.AddCommonFlags(ledgerTransactionCmd.Flags()) + utils.AddArchiveFlags("ledger_transaction", ledgerTransactionCmd.Flags()) + utils.AddGcsFlags(ledgerTransactionCmd.Flags()) + ledgerTransactionCmd.MarkFlagRequired("end-ledger") /* Current flags: start-ledger: the ledger sequence number for the beginning of the export period end-ledger: the ledger sequence number for the end of the export range (*required) - limit: maximum number of tx to export - TODO: measure a good default value that ensures all tx within a 5 minute period will be exported with a single call - The current max_tx_set_size is 1000 and there are 60 new ledgers in a 5 minute period: + limit: maximum number of ledger_transaction to export + TODO: measure a good default value that ensures all ledger_transaction within a 5 minute period will be exported with a single call + The current max_ledger_transaction_set_size is 1000 and there are 60 new ledgers in a 5 minute period: 1000*60 = 60000 output-file: filename of the output file diff --git a/internal/transform/tx.go b/internal/transform/ledger_transaction.go similarity index 67% rename from internal/transform/tx.go rename to internal/transform/ledger_transaction.go index 3adda449..f295e6fd 100644 --- a/internal/transform/tx.go +++ b/internal/transform/ledger_transaction.go @@ -10,41 +10,41 @@ import ( ) // TransformTransaction converts a transaction from the history archive ingestion system into a form suitable for BigQuery -func TransformTx(transaction ingest.LedgerTransaction, lhe xdr.LedgerHeaderHistoryEntry) (TxOutput, error) { +func TransformLedgerTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHeaderHistoryEntry) (LedgerTransactionOutput, error) { ledgerHeader := lhe.Header outputLedgerSequence := uint32(ledgerHeader.LedgerSeq) outputTxEnvelope, err := xdr.MarshalBase64(transaction.Envelope) if err != nil { - return TxOutput{}, err + return LedgerTransactionOutput{}, err } outputTxResult, err := xdr.MarshalBase64(&transaction.Result) if err != nil { - return TxOutput{}, err + return LedgerTransactionOutput{}, err } outputTxMeta, err := xdr.MarshalBase64(transaction.UnsafeMeta) if err != nil { - return TxOutput{}, err + return LedgerTransactionOutput{}, err } outputTxFeeMeta, err := xdr.MarshalBase64(transaction.FeeChanges) if err != nil { - return TxOutput{}, err + return LedgerTransactionOutput{}, err } outputTxLedgerHistory, err := xdr.MarshalBase64(lhe) if err != nil { - return TxOutput{}, err + return LedgerTransactionOutput{}, err } outputCloseTime, err := utils.TimePointToUTCTimeStamp(ledgerHeader.ScpValue.CloseTime) if err != nil { - return TxOutput{}, fmt.Errorf("could not convert close time to UTC timestamp: %v", err) + return LedgerTransactionOutput{}, fmt.Errorf("could not convert close time to UTC timestamp: %v", err) } - transformedTx := TxOutput{ + transformedLedgerTransaction := LedgerTransactionOutput{ LedgerSequence: outputLedgerSequence, TxEnvelope: outputTxEnvelope, TxResult: outputTxResult, @@ -54,5 +54,5 @@ func TransformTx(transaction ingest.LedgerTransaction, lhe xdr.LedgerHeaderHisto ClosedAt: outputCloseTime, } - return transformedTx, nil + return transformedLedgerTransaction, nil } diff --git a/internal/transform/tx_test.go b/internal/transform/ledger_transaction_test.go similarity index 94% rename from internal/transform/tx_test.go rename to internal/transform/ledger_transaction_test.go index 7e489021..7e53e63d 100644 --- a/internal/transform/tx_test.go +++ b/internal/transform/ledger_transaction_test.go @@ -17,35 +17,35 @@ func TestTransformTx(t *testing.T) { } type transformTest struct { input inputStruct - wantOutput TxOutput + wantOutput LedgerTransactionOutput wantErr error } - hardCodedTx, hardCodedLedgerHeader, err := makeTxTestInput() + hardCodedLedgerTransaction, hardCodedLedgerHeader, err := makeLedgerTransactionTestInput() assert.NoError(t, err) - hardCodedOutput, err := makeTxTestOutput() + hardCodedOutput, err := makeLedgerTransactionTestOutput() assert.NoError(t, err) tests := []transformTest{} - for i := range hardCodedTx { + for i := range hardCodedLedgerTransaction { tests = append(tests, transformTest{ - input: inputStruct{hardCodedTx[i], hardCodedLedgerHeader[i]}, + input: inputStruct{hardCodedLedgerTransaction[i], hardCodedLedgerHeader[i]}, wantOutput: hardCodedOutput[i], wantErr: nil, }) } for _, test := range tests { - actualOutput, actualError := TransformTx(test.input.transaction, test.input.historyHeader) + actualOutput, actualError := TransformLedgerTransaction(test.input.transaction, test.input.historyHeader) assert.Equal(t, test.wantErr, actualError) assert.Equal(t, test.wantOutput, actualOutput) } } -func makeTxTestOutput() (output []TxOutput, err error) { - output = []TxOutput{ - TxOutput{ +func makeLedgerTransactionTestOutput() (output []LedgerTransactionOutput, err error) { + output = []LedgerTransactionOutput{ + LedgerTransactionOutput{ TxEnvelope: "AAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAABX5ABjydzAABBtwAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0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LbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA", @@ -54,7 +54,7 @@ func makeTxTestOutput() (output []TxOutput, err error) { LedgerSequence: 30521816, ClosedAt: time.Date(2020, time.July, 9, 5, 28, 42, 0, time.UTC), }, - TxOutput{ + LedgerTransactionOutput{ TxEnvelope: "AAAABQAAAABnzACGTDuJFoxqr+C8NHCe0CHFBXLi+YhhNCIILCIpcgAAAAAAABwgAAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAAAAAACFPY2AAAAfQAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", TxResult: "qH/vXusmAmnDgPLeRWqtcrWbsxWqrHd4YEVuCdrAuvsAAAAAAAABLAAAAAGof+9e6yYCacOA8t5Faq1ytZuzFaqsd3hgRW4J2sC6+wAAAAAAAABkAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA==", TxMeta: "AAAAAQAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA", @@ -63,7 +63,7 @@ func makeTxTestOutput() (output []TxOutput, err error) { LedgerSequence: 30521817, ClosedAt: time.Date(2020, time.July, 9, 5, 28, 42, 0, time.UTC), }, - TxOutput{ + LedgerTransactionOutput{ TxEnvelope: "AAAAAgAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAGQBpLyvsiV6gwAAAAIAAAABAAAAAAAAAAAAAAAAXwardAAAAAEAAAAFAAAACgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAMCAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDA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AfYAAAAAAAAAGgAAAAAAAAAA", @@ -75,7 +75,7 @@ func makeTxTestOutput() (output []TxOutput, err error) { } return } -func makeTxTestInput() (transaction []ingest.LedgerTransaction, historyHeader []xdr.LedgerHeaderHistoryEntry, err error) { +func makeLedgerTransactionTestInput() (transaction []ingest.LedgerTransaction, historyHeader []xdr.LedgerHeaderHistoryEntry, err error) { hardCodedMemoText := "HL5aCgozQHIW7sSc5XdcfmR" hardCodedTransactionHash := xdr.Hash([32]byte{0xa8, 0x7f, 0xef, 0x5e, 0xeb, 0x26, 0x2, 0x69, 0xc3, 0x80, 0xf2, 0xde, 0x45, 0x6a, 0xad, 0x72, 0xb5, 0x9b, 0xb3, 0x15, 0xaa, 0xac, 0x77, 0x78, 0x60, 0x45, 0x6e, 0x9, 0xda, 0xc0, 0xba, 0xfb}) genericResultResults := &[]xdr.OperationResult{ diff --git a/internal/transform/schema.go b/internal/transform/schema.go index e544294c..0668da11 100644 --- a/internal/transform/schema.go +++ b/internal/transform/schema.go @@ -66,7 +66,7 @@ type TransactionOutput struct { SorobanResourcesWriteBytes uint32 `json:"soroban_resources_write_bytes"` } -type TxOutput struct { +type LedgerTransactionOutput struct { LedgerSequence uint32 `json:"ledger_sequence"` TxEnvelope string `json:"tx_envelope"` TxResult string `json:"tx_result"`