Skip to content

Commit

Permalink
feat: update id types from node admin (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai authored May 24, 2024
1 parent 988d92d commit f3be033
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions node/pkg/admin/config/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type BulkConfigs struct {
type FeedInsertModel struct {
Name string `db:"name" json:"name" validate:"required"`
Definition json.RawMessage `db:"definition" json:"definition" validate:"required"`
ConfigId *int64 `db:"config_id" json:"configId"`
ConfigId *int32 `db:"config_id" json:"configId"`
}

type ConfigInsertModel struct {
Expand All @@ -31,7 +31,7 @@ type ConfigInsertModel struct {
}

type ConfigModel struct {
Id int64 `db:"id" json:"id"`
Id int32 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
FetchInterval *int `db:"fetch_interval" json:"fetchInterval"`
AggregateInterval *int `db:"aggregate_interval" json:"aggregateInterval"`
Expand All @@ -40,7 +40,7 @@ type ConfigModel struct {

type ConfigNameIdModel struct {
Name string `db:"name" json:"name"`
Id int64 `db:"id" json:"id"`
Id int32 `db:"id" json:"id"`
}

func Sync(c *fiber.Ctx) error {
Expand Down Expand Up @@ -103,7 +103,7 @@ func Sync(c *fiber.Ctx) error {
return err
}

configNameIdMap := map[string]int64{}
configNameIdMap := map[string]int32{}
for _, configId := range configIds {
configNameIdMap[configId.Name] = configId.Id
}
Expand Down
4 changes: 2 additions & 2 deletions node/pkg/admin/feed/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
)

type FeedModel struct {
Id *int64 `db:"id" json:"id"`
Id *int32 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Definition json.RawMessage `db:"definition" json:"definition"`
ConfigId *int64 `db:"config_id" json:"configId"`
ConfigId *int32 `db:"config_id" json:"configId"`
}

func get(c *fiber.Ctx) error {
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/admin/providerUrl/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type ProviderUrlModel struct {
Id *int64 `db:"id" json:"id"`
Id *int32 `db:"id" json:"id"`
ChainId *int `db:"chain_id" json:"chain_id"`
Url string `db:"url" json:"url"`
Priority *int `db:"priority" json:"priority"`
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/admin/proxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type ProxyModel struct {
Id *int64 `db:"id" json:"id"`
Id *int32 `db:"id" json:"id"`
Protocol string `db:"protocol" json:"protocol"`
Host string `db:"host" json:"host"`
Port int `db:"port" json:"port"`
Expand Down
4 changes: 2 additions & 2 deletions node/pkg/admin/tests/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestAggregatorActivate(t *testing.T) {
channel := testItems.mb.Subscribe(bus.AGGREGATOR)
waitForMessage(t, channel, bus.ADMIN, bus.AGGREGATOR, bus.ACTIVATE_AGGREGATOR)

_, err = RawPostRequest(testItems.app, "/api/v1/aggregator/activate/"+strconv.FormatInt(testItems.tmpData.config.Id, 10), nil)
_, err = RawPostRequest(testItems.app, "/api/v1/aggregator/activate/"+strconv.Itoa(int(testItems.tmpData.config.Id)), nil)
if err != nil {
t.Fatalf("error activating aggregator: %v", err)
}
Expand All @@ -98,7 +98,7 @@ func TestAggregatorDeactivate(t *testing.T) {
channel := testItems.mb.Subscribe(bus.AGGREGATOR)
waitForMessage(t, channel, bus.ADMIN, bus.AGGREGATOR, bus.DEACTIVATE_AGGREGATOR)

_, err = RawPostRequest(testItems.app, "/api/v1/aggregator/deactivate/"+strconv.FormatInt(testItems.tmpData.config.Id, 10), nil)
_, err = RawPostRequest(testItems.app, "/api/v1/aggregator/deactivate/"+strconv.Itoa(int(testItems.tmpData.config.Id)), nil)
if err != nil {
t.Fatalf("error deactivating aggregator: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/admin/tests/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestConfigSync(t *testing.T) {
}
assert.Equal(t, config.ConfigModel{}, readTmpConfigResult)

readTmpFeedResult, err := GetRequest[feed.FeedModel](testItems.app, "/api/v1/feed/"+strconv.FormatInt(*testItems.tmpData.feed.Id, 10), nil)
readTmpFeedResult, err := GetRequest[feed.FeedModel](testItems.app, "/api/v1/feed/"+strconv.Itoa(int(*testItems.tmpData.feed.Id)), nil)
if err != nil {
t.Fatalf("error getting feeds: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions node/pkg/admin/tests/feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestFeedGetByConfigId(t *testing.T) {
}
defer cleanup()

readResult, err := GetRequest[[]feed.FeedModel](testItems.app, "/api/v1/feed/config/"+strconv.FormatInt(testItems.tmpData.config.Id, 10), nil)
readResult, err := GetRequest[[]feed.FeedModel](testItems.app, "/api/v1/feed/config/"+strconv.Itoa(int(testItems.tmpData.config.Id)), nil)
if err != nil {
t.Fatalf("error getting feeds: %v", err)
}
Expand All @@ -49,7 +49,7 @@ func TestFeedGetById(t *testing.T) {
}
defer cleanup()

readResult, err := GetRequest[feed.FeedModel](testItems.app, "/api/v1/feed/"+strconv.FormatInt(*testItems.tmpData.feed.Id, 10), nil)
readResult, err := GetRequest[feed.FeedModel](testItems.app, "/api/v1/feed/"+strconv.Itoa(int(*testItems.tmpData.feed.Id)), nil)
if err != nil {
t.Fatalf("error getting feeds: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions node/pkg/admin/tests/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestFetcherDeactivate(t *testing.T) {
channel := testItems.mb.Subscribe(bus.FETCHER)
waitForMessage(t, channel, bus.ADMIN, bus.FETCHER, bus.DEACTIVATE_FETCHER)

_, err = RawPostRequest(testItems.app, "/api/v1/fetcher/deactivate/"+strconv.FormatInt(testItems.tmpData.config.Id, 10), nil)
_, err = RawPostRequest(testItems.app, "/api/v1/fetcher/deactivate/"+strconv.Itoa(int(testItems.tmpData.config.Id)), nil)
if err != nil {
t.Fatalf("error deactivating adapter: %v", err)
}
Expand All @@ -96,7 +96,7 @@ func TestAdapterActivate(t *testing.T) {
waitForMessage(t, channel, bus.ADMIN, bus.FETCHER, bus.ACTIVATE_FETCHER)

// activate
_, err = RawPostRequest(testItems.app, "/api/v1/fetcher/activate/"+strconv.FormatInt(testItems.tmpData.config.Id, 10), nil)
_, err = RawPostRequest(testItems.app, "/api/v1/fetcher/activate/"+strconv.Itoa(int(testItems.tmpData.config.Id)), nil)
if err != nil {
t.Fatalf("error activating adapter: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/admin/tests/providerUrl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestProviderUrlGetById(t *testing.T) {
}
defer cleanup()

readResult, err := GetRequest[providerUrl.ProviderUrlModel](testItems.app, "/api/v1/provider-url/"+strconv.FormatInt(*testItems.tmpData.providerUrl.Id, 10), nil)
readResult, err := GetRequest[providerUrl.ProviderUrlModel](testItems.app, "/api/v1/provider-url/"+strconv.Itoa(int(*testItems.tmpData.providerUrl.Id)), nil)
if err != nil {
t.Fatalf("error getting provider urls: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions node/pkg/admin/tests/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestProxyGetById(t *testing.T) {
}
defer cleanup()

readResultById, err := GetRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.FormatInt(*testItems.tmpData.proxy.Id, 10), nil)
readResultById, err := GetRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.Itoa(int(*testItems.tmpData.proxy.Id)), nil)
if err != nil {
t.Fatalf("error getting proxy by id: %v", err)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestProxyUpdateById(t *testing.T) {
Location: nil,
}

updateResult, err := PatchRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.FormatInt(*insertResult.Id, 10), mockProxyUpdate)
updateResult, err := PatchRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.Itoa(int(*insertResult.Id)), mockProxyUpdate)
if err != nil {
t.Fatalf("error updating proxy: %v", err)
}
Expand Down Expand Up @@ -144,12 +144,12 @@ func TestProxyDeleteById(t *testing.T) {
t.Fatalf("error inserting proxy: %v", err)
}

_, err = DeleteRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.FormatInt(*insertResult.Id, 10), nil)
_, err = DeleteRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.Itoa(int(*insertResult.Id)), nil)
if err != nil {
t.Fatalf("error deleting proxy: %v", err)
}

result, err := GetRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.FormatInt(*insertResult.Id, 10), nil)
result, err := GetRequest[proxy.ProxyModel](testItems.app, "/api/v1/proxy/"+strconv.Itoa(int(*insertResult.Id)), nil)
if err != nil {
t.Fatalf("error getting proxy by id: %v", err)
}
Expand Down
12 changes: 6 additions & 6 deletions node/pkg/admin/tests/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestWalletInsert(t *testing.T) {

assert.Greaterf(t, len(readResultAfter), len(readResultBefore), "expected to have more wallets after insertion")

readSingle, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.FormatInt(*insertResult.Id, 10), nil)
readSingle, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.Itoa(int(*insertResult.Id)), nil)
if err != nil {
t.Fatalf("error getting wallet by id: %v", err)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestWalletGetById(t *testing.T) {
}
defer cleanup()

readResultById, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.FormatInt(*testItems.tmpData.wallet.Id, 10), nil)
readResultById, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.Itoa(int(*testItems.tmpData.wallet.Id)), nil)
if err != nil {
t.Fatalf("error getting wallet by id: %v", err)
}
Expand All @@ -122,12 +122,12 @@ func TestWalletUpdateById(t *testing.T) {
Pk: "0x7b48c1fd1861ebc850e3a8629198e9c4d33fc16ff995162a25438b532c42253d",
}

beforeUpdate, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.FormatInt(*testItems.tmpData.wallet.Id, 10), nil)
beforeUpdate, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.Itoa(int(*testItems.tmpData.wallet.Id)), nil)
if err != nil {
t.Fatalf("error getting wallet by id before update: %v", err)
}

updateResult, err := PatchRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.FormatInt(*testItems.tmpData.wallet.Id, 10), map[string]any{"pk": mockWallet.Pk})
updateResult, err := PatchRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.Itoa(int(*testItems.tmpData.wallet.Id)), map[string]any{"pk": mockWallet.Pk})
if err != nil {
t.Fatalf("error updating wallet: %v", err)
}
Expand All @@ -149,7 +149,7 @@ func TestWalletDeleteById(t *testing.T) {
t.Fatalf("error getting wallets before: %v", err)
}

removeResult, err := DeleteRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.FormatInt(*testItems.tmpData.wallet.Id, 10), nil)
removeResult, err := DeleteRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.Itoa(int(*testItems.tmpData.wallet.Id)), nil)
if err != nil {
t.Fatalf("error deleting wallet: %v", err)
}
Expand All @@ -161,7 +161,7 @@ func TestWalletDeleteById(t *testing.T) {

assert.Lessf(t, len(readResultAfter), len(readResultBefore), "expected to have less wallets after deletion")

failReadAfterDelete, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.FormatInt(*removeResult.Id, 10), nil)
failReadAfterDelete, err := GetRequest[wallet.WalletModel](testItems.app, "/api/v1/wallet/"+strconv.Itoa(int(*removeResult.Id)), nil)
if err != nil {
t.Fatalf("error getting wallet by id after deletion: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/admin/wallet/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type WalletModel struct {
Id *int64 `db:"id" json:"id"`
Id *int32 `db:"id" json:"id"`
Pk string `db:"pk" json:"pk"`
}

Expand Down

0 comments on commit f3be033

Please sign in to comment.