Skip to content

Commit

Permalink
Remove amount and num_accounts from ExpAssetStats table and test fixt…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
karthikiyer56 committed Sep 30, 2024
1 parent b4d4edc commit 102fe5f
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 169 deletions.
10 changes: 0 additions & 10 deletions services/horizon/internal/actions/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "10",
LiquidityPools: "20",
},
Amount: "1",
NumAccounts: 2,
}
usdAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand Down Expand Up @@ -185,8 +183,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "23",
NumAccounts: 1,
}
etherAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand Down Expand Up @@ -230,8 +226,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "1",
NumAccounts: 2,
}
otherUSDAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand Down Expand Up @@ -277,8 +271,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "111",
NumAccounts: 3,
}
eurAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand Down Expand Up @@ -445,8 +437,6 @@ func TestAssetStatsIssuerDoesNotExist(t *testing.T) {
Unauthorized: "3",
ClaimableBalances: "0",
},
Amount: "1",
NumAccounts: 2,
}
numChanged, err := q.InsertAssetStat(tt.Ctx, usdAssetStat)
tt.Assert.NoError(err)
Expand Down
2 changes: 0 additions & 2 deletions services/horizon/internal/db2/history/asset_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ func assetStatToMap(assetStat ExpAssetStat) map[string]interface{} {
"asset_issuer": assetStat.AssetIssuer,
"accounts": assetStat.Accounts,
"balances": assetStat.Balances,
"amount": assetStat.Amount,
"num_accounts": assetStat.NumAccounts,
"contract_id": assetStat.ContractID,
}
}
Expand Down
46 changes: 0 additions & 46 deletions services/horizon/internal/db2/history/asset_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func TestAssetStatContracts(t *testing.T) {
LiquidityPools: "0",
Unauthorized: "0",
},
Amount: "0",
NumAccounts: 0,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12,
Expand All @@ -59,8 +57,6 @@ func TestAssetStatContracts(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "23",
NumAccounts: 1,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4,
Expand All @@ -78,8 +74,6 @@ func TestAssetStatContracts(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
},
}
var contractID [32]byte
Expand Down Expand Up @@ -219,8 +213,6 @@ func TestInsertAssetStats(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12,
Expand All @@ -238,8 +230,6 @@ func TestInsertAssetStats(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "23",
NumAccounts: 1,
},
}
tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats))
Expand Down Expand Up @@ -276,8 +266,6 @@ func TestInsertAssetStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12,
Expand All @@ -295,8 +283,6 @@ func TestInsertAssetStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "23",
NumAccounts: 1,
},
}

Expand Down Expand Up @@ -333,8 +319,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat)
Expand All @@ -344,18 +328,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) {
numChanged, err = q.InsertAssetStat(tt.Ctx, assetStat)
tt.Assert.Error(err)
tt.Assert.Equal(numChanged, int64(0))

assetStat.NumAccounts = 4
assetStat.Amount = "3"
numChanged, err = q.InsertAssetStat(tt.Ctx, assetStat)
tt.Assert.Error(err)
tt.Assert.Equal(numChanged, int64(0))

assetStat.NumAccounts = 2
assetStat.Amount = "1"
got, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer)
tt.Assert.NoError(err)
tt.Assert.Equal(got, assetStat)
}

func TestUpdateAssetStatDoesNotExistsError(t *testing.T) {
Expand All @@ -380,8 +352,6 @@ func TestUpdateAssetStatDoesNotExistsError(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.UpdateAssetStat(tt.Ctx, assetStat)
Expand Down Expand Up @@ -415,8 +385,6 @@ func TestUpdateStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat)
Expand All @@ -427,8 +395,6 @@ func TestUpdateStat(t *testing.T) {
tt.Assert.NoError(err)
tt.Assert.Equal(got, assetStat)

assetStat.NumAccounts = 50
assetStat.Amount = "23"
assetStat.SetContractID([32]byte{23})

numChanged, err = q.UpdateAssetStat(tt.Ctx, assetStat)
Expand Down Expand Up @@ -462,8 +428,6 @@ func TestGetAssetStatDoesNotExist(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

_, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer)
Expand Down Expand Up @@ -493,8 +457,6 @@ func TestRemoveAssetStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.RemoveAssetStat(tt.Ctx,
Expand Down Expand Up @@ -628,8 +590,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "1",
NumAccounts: 2,
},
Contracts: zero,
}
Expand All @@ -650,8 +610,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "23",
NumAccounts: 1,
},
Contracts: zero,
}
Expand All @@ -672,8 +630,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "1",
NumAccounts: 2,
},
Contracts: zero,
}
Expand All @@ -694,8 +650,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "1",
LiquidityPools: "2",
},
Amount: "111",
NumAccounts: 3,
},
Contracts: ContractStat{
ActiveBalance: "120",
Expand Down
6 changes: 1 addition & 5 deletions services/horizon/internal/db2/history/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,6 @@ type ExpAssetStat struct {
AssetIssuer string `db:"asset_issuer"`
Accounts ExpAssetStatAccounts `db:"accounts"`
Balances ExpAssetStatBalances `db:"balances"`
Amount string `db:"amount"`
NumAccounts int32 `db:"num_accounts"`
ContractID *[]byte `db:"contract_id"`
// make sure to update Equals() when adding new fields to ExpAssetStat
}
Expand Down Expand Up @@ -481,9 +479,7 @@ func (e *ExpAssetStat) Equals(o ExpAssetStat) bool {
e.AssetCode == o.AssetCode &&
e.AssetIssuer == o.AssetIssuer &&
e.Accounts == o.Accounts &&
e.Balances == o.Balances &&
e.Amount == o.Amount &&
e.NumAccounts == o.NumAccounts
e.Balances == o.Balances
}

func (e *ExpAssetStat) GetContractID() ([32]byte, bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ func IncludeContractIDsInAssetStats(
AssetIssuer: assetIssuer,
Accounts: history.ExpAssetStatAccounts{},
Balances: newAssetStatBalance().ConvertToHistoryObject(),
Amount: "0",
NumAccounts: 0,
}
row.SetContractID(contractID)
assetStatsDeltas = append(assetStatsDeltas, row)
Expand Down Expand Up @@ -456,8 +454,6 @@ func (p *AssetStatsProcessor) updateAssetStats(
AssetIssuer: delta.AssetIssuer,
Accounts: statAccounts,
Balances: statBalances.ConvertToHistoryObject(),
Amount: statBalances.Authorized.String(),
NumAccounts: statAccounts.Authorized,
ContractID: delta.ContractID,
})
if err != nil {
Expand Down Expand Up @@ -549,8 +545,6 @@ func (p *AssetStatsProcessor) updateContractID(
AssetIssuer: assetIssuer,
Accounts: history.ExpAssetStatAccounts{},
Balances: newAssetStatBalance().ConvertToHistoryObject(),
Amount: "0",
NumAccounts: 0,
}
row.SetContractID(contractID)

Expand Down
Loading

0 comments on commit 102fe5f

Please sign in to comment.