Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chowbao committed Nov 2, 2023
1 parent df85b2d commit f3ff066
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 24 deletions.
7 changes: 3 additions & 4 deletions internal/input/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package input

import (
"testing"
"time"

"github.com/stellar/go/ingest"
"github.com/stellar/go/ingest/ledgerbackend"
Expand Down Expand Up @@ -115,12 +114,12 @@ func TestSendBatchToChannel(t *testing.T) {
}

func wrapLedgerEntry(entryType xdr.LedgerEntryType, entry xdr.LedgerEntry) ChangeBatch {
changes := map[xdr.LedgerEntryType]ChangesClosedAt{
changes := map[xdr.LedgerEntryType]LedgerChanges{
entryType: {
Changes: []ingest.Change{
{Type: entry.Data.Type, Post: &entry},
},
ClosedAts: []time.Time{},
LedgerHeaders: []xdr.LedgerHeaderHistoryEntry{},
},
}
return ChangeBatch{
Expand All @@ -134,7 +133,7 @@ func mockExtractBatch(
env utils.EnvironmentDetails, logger *utils.EtlLogger) ChangeBatch {
log.Errorf("mock called")
return ChangeBatch{
Changes: map[xdr.LedgerEntryType]ChangesClosedAt{},
Changes: map[xdr.LedgerEntryType]LedgerChanges{},
BatchStart: batchStart,
BatchEnd: batchEnd,
}
Expand Down
17 changes: 15 additions & 2 deletions internal/transform/account_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ func TestTransformAccountSigner(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformSigners(test.input.injest, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformSigners(test.input.injest, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -131,6 +138,8 @@ func makeSignersTestOutput() []AccountSignerOutput {
LastModifiedLedger: 30705278,
LedgerEntryChange: 2,
Deleted: true,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
}, {
AccountID: testAccount1ID.Address(),
Signer: "GACAKBQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB3BQ",
Expand All @@ -139,6 +148,8 @@ func makeSignersTestOutput() []AccountSignerOutput {
LastModifiedLedger: 30705278,
LedgerEntryChange: 2,
Deleted: true,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
}, {
AccountID: testAccount1ID.Address(),
Signer: "GAFAWDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABNDC",
Expand All @@ -147,6 +158,8 @@ func makeSignersTestOutput() []AccountSignerOutput {
LastModifiedLedger: 30705278,
LedgerEntryChange: 2,
Deleted: true,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
}
}
13 changes: 11 additions & 2 deletions internal/transform/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ func TestTransformAccount(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformAccount(test.input.ledgerChange, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformAccount(test.input.ledgerChange, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -183,5 +190,7 @@ func makeAccountTestOutput() AccountOutput {
LastModifiedLedger: 30705278,
LedgerEntryChange: 2,
Deleted: true,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
}
}
13 changes: 11 additions & 2 deletions internal/transform/claimable_balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ func TestTransformClaimableBalance(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformClaimableBalance(test.input.ingest, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformClaimableBalance(test.input.ingest, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -117,5 +124,7 @@ func makeClaimableBalanceTestOutput() ClaimableBalanceOutput {
LastModifiedLedger: 30705278,
LedgerEntryChange: 2,
Deleted: true,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
}
}
13 changes: 11 additions & 2 deletions internal/transform/config_setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ func TestTransformConfigSetting(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformConfigSetting(test.input, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformConfigSetting(test.input, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -126,6 +133,8 @@ func makeConfigSettingTestOutput() []ConfigSettingOutput {
LastModifiedLedger: 24229503,
LedgerEntryChange: 1,
Deleted: false,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
}
}
13 changes: 11 additions & 2 deletions internal/transform/contract_code_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ func TestTransformContractCode(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformContractCode(test.input, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformContractCode(test.input, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -84,6 +91,8 @@ func makeContractCodeTestOutput() []ContractCodeOutput {
LastModifiedLedger: 24229503,
LedgerEntryChange: 1,
Deleted: false,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
}
}
13 changes: 11 additions & 2 deletions internal/transform/contract_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ func TestTransformContractData(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
TransformContractData := NewTransformContractDataStruct(MockAssetFromContractData, MockContractBalanceFromContractData)
actualOutput, actualError, _ := TransformContractData.TransformContractData(test.input, test.passphrase, closedAt)
actualOutput, actualError, _ := TransformContractData.TransformContractData(test.input, test.passphrase, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -129,6 +136,8 @@ func makeContractDataTestOutput() []ContractDataOutput {
LastModifiedLedger: 24229503,
LedgerEntryChange: 1,
Deleted: false,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
}
}
13 changes: 11 additions & 2 deletions internal/transform/expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ func TestTransformExpiration(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformExpiration(test.input, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformExpiration(test.input, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -93,6 +100,8 @@ func makeExpirationTestOutput() []ExpirationOutput {
LastModifiedLedger: 1,
LedgerEntryChange: 1,
Deleted: false,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
}
}
13 changes: 11 additions & 2 deletions internal/transform/liquidity_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ func TestTransformPool(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformPool(test.input.ingest, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformPool(test.input.ingest, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -118,5 +125,7 @@ func makePoolTestOutput() PoolOutput {
LastModifiedLedger: 30705278,
LedgerEntryChange: 2,
Deleted: true,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
}
}
13 changes: 11 additions & 2 deletions internal/transform/offer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ func TestTransformOffer(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformOffer(test.input.ingest, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformOffer(test.input.ingest, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -171,5 +178,7 @@ func makeOfferTestOutput() OfferOutput {
LedgerEntryChange: 2,
Deleted: true,
Sponsor: null.StringFrom(testAccount3Address),
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
}
}
15 changes: 13 additions & 2 deletions internal/transform/trustline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@ func TestTransformTrustline(t *testing.T) {
}

for _, test := range tests {
var closedAt time.Time
actualOutput, actualError := TransformTrustline(test.input.ingest, closedAt)
header := xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
ScpValue: xdr.StellarValue{
CloseTime: 1000,
},
LedgerSeq: 10,
},
}
actualOutput, actualError := TransformTrustline(test.input.ingest, header)
assert.Equal(t, test.wantErr, actualError)
assert.Equal(t, test.wantOutput, actualOutput)
}
Expand Down Expand Up @@ -133,6 +140,8 @@ func makeTrustlineTestOutput() []TrustlineOutput {
LastModifiedLedger: 24229503,
LedgerEntryChange: 1,
Deleted: false,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
{
LedgerKey: "AAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAMBAwQFBwkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
Expand All @@ -148,6 +157,8 @@ func makeTrustlineTestOutput() []TrustlineOutput {
LastModifiedLedger: 123456789,
LedgerEntryChange: 1,
Deleted: false,
LedgerSequence: 10,
ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC),
},
}
}

0 comments on commit f3ff066

Please sign in to comment.