-
Notifications
You must be signed in to change notification settings - Fork 2
Update usages of Cfg to use app.config and use static senders for rewards #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ import ( | |
| "testing" | ||
| "time" | ||
|
|
||
| "api.audius.co/config" | ||
| "api.audius.co/database" | ||
| "github.com/gagliardetto/solana-go" | ||
| "github.com/mr-tron/base58" | ||
|
|
@@ -41,9 +40,9 @@ func TestV1CreateRewardCode(t *testing.T) { | |
| database.Seed(app.pool.Replicas[0], fixtures) | ||
|
|
||
| // Save original config and restore after tests | ||
| originalKeys := config.Cfg.RewardCodeAuthorizedKeys | ||
| originalKeys := app.config.RewardCodeAuthorizedKeys | ||
| defer func() { | ||
| config.Cfg.RewardCodeAuthorizedKeys = originalKeys | ||
| app.config.RewardCodeAuthorizedKeys = originalKeys | ||
| }() | ||
|
|
||
| t.Run("Unauthorized with invalid signature", func(t *testing.T) { | ||
|
|
@@ -112,7 +111,7 @@ func TestV1CreateRewardCode(t *testing.T) { | |
| // Convert to Solana format and inject into config | ||
| solanaPubKey := solana.PublicKeyFromBytes(testPublicKey) | ||
| testPubKeyBase58 := solanaPubKey.String() | ||
| config.Cfg.RewardCodeAuthorizedKeys = []string{testPubKeyBase58} | ||
| app.config.RewardCodeAuthorizedKeys = []string{testPubKeyBase58} | ||
|
|
||
| timestamp := time.Now().UnixMilli() | ||
| timestampStr := fmt.Sprintf("%d", timestamp) | ||
|
|
@@ -164,7 +163,7 @@ func TestV1CreateRewardCode(t *testing.T) { | |
| solanaPubKey2 := solana.PublicKeyFromBytes(testPublicKey2) | ||
| testPubKeyBase58 := solanaPubKey.String() | ||
| testPubKeyBase582 := solanaPubKey2.String() | ||
| config.Cfg.RewardCodeAuthorizedKeys = []string{testPubKeyBase58, testPubKeyBase582} | ||
| app.config.RewardCodeAuthorizedKeys = []string{testPubKeyBase58, testPubKeyBase582} | ||
|
|
||
| timestamp := time.Now().UnixMilli() | ||
| timestampStr := fmt.Sprintf("%d", timestamp) | ||
|
|
@@ -212,7 +211,7 @@ func TestV1CreateRewardCode(t *testing.T) { | |
| // Convert to Solana format and inject into config | ||
| solanaPubKey := solana.PublicKeyFromBytes(testPublicKey) | ||
| testPubKeyBase58 := solanaPubKey.String() | ||
| config.Cfg.RewardCodeAuthorizedKeys = []string{testPubKeyBase58} | ||
| app.config.RewardCodeAuthorizedKeys = []string{testPubKeyBase58} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should really just stick these into the test config, but leaving as-is for now |
||
|
|
||
| timestamp := time.Now().UnixMilli() | ||
| timestampStr := fmt.Sprintf("%d", timestamp) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ func newTestConfig() config.Config { | |
| } | ||
|
|
||
| func TestRecordBalanceHistory(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -153,7 +153,7 @@ func TestRecordBalanceHistory(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryTimestampTruncation(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -193,7 +193,7 @@ func TestRecordBalanceHistoryTimestampTruncation(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryConflictHandling(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi @dylanjeffers sorry I didn't catch this in initial review - each "package" of tests in go runs in parallel, and only one database can be created from a template at a time, so each package has its own template to use for tests to avoid race conditions super annoying footgun but it makes tests faasstt |
||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -248,7 +248,7 @@ func TestRecordBalanceHistoryConflictHandling(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryZeroBalance(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -284,7 +284,7 @@ func TestRecordBalanceHistoryZeroBalance(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryNullPrice(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -320,7 +320,7 @@ func TestRecordBalanceHistoryNullPrice(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordUserBalanceHistory(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -368,7 +368,7 @@ func TestRecordUserBalanceHistory(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryMultipleMints(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -415,7 +415,7 @@ func TestRecordBalanceHistoryMultipleMints(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryConcurrentRuns(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -460,7 +460,7 @@ func TestRecordBalanceHistoryConcurrentRuns(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryNoUsers(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -487,7 +487,7 @@ func TestRecordBalanceHistoryNoUsers(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryDecimalPrecision(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
@@ -553,7 +553,7 @@ func TestRecordBalanceHistoryDecimalPrecision(t *testing.T) { | |
| } | ||
|
|
||
| func TestRecordBalanceHistoryOnlyTrackedCoins(t *testing.T) { | ||
| pool := database.CreateTestDatabase(t, "test_api") | ||
| pool := database.CreateTestDatabase(t, "test_jobs") | ||
| defer pool.Close() | ||
|
|
||
| ctx := context.Background() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this change from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we depend on this being devnet for the block_confirmation tests. I didn't realize we had a whole separate config we started here for tests :P