-
Notifications
You must be signed in to change notification settings - Fork 246
feat: implement multi-account support with round-robin address selection #2785
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dc05911
feat: implement multi-account support with round-robin address select…
randygrok 80db3ba
Merge branch 'main' into feat/multiple-accounts-da-submit
randygrok 9d34697
Update pkg/config/config.go
randygrok 6ac2c90
Update docs/learn/config.md
randygrok 9c4ffcd
fix: ensure options map is initialized correctly in mergeSubmitOption…
randygrok 63fc1f9
feat: add support for DA signing addresses in entrypoint script
randygrok d87adf5
Update pkg/config/config.go
randygrok 8933b17
update flag
randygrok c6ef531
fix: improve error handling in RoundRobinSelector for empty address c…
randygrok e7c9e4b
Merge branch 'main' into feat/multiple-accounts-da-submit
tac0turtle 82a1303
fix build after conflict resolution
tac0turtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| package submitting | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestMergeSubmitOptions_NoSigningAddress(t *testing.T) { | ||
| baseOptions := []byte(`{"key":"value"}`) | ||
|
|
||
| result, err := mergeSubmitOptions(baseOptions, "") | ||
| require.NoError(t, err) | ||
| assert.Equal(t, baseOptions, result, "should return unchanged options when no signing address") | ||
| } | ||
|
|
||
| func TestMergeSubmitOptions_EmptyBaseOptions(t *testing.T) { | ||
| signingAddress := "celestia1abc123" | ||
|
|
||
| result, err := mergeSubmitOptions([]byte{}, signingAddress) | ||
| require.NoError(t, err) | ||
|
|
||
| var resultMap map[string]interface{} | ||
| err = json.Unmarshal(result, &resultMap) | ||
| require.NoError(t, err) | ||
|
|
||
| assert.Equal(t, signingAddress, resultMap["signer_address"]) | ||
| } | ||
|
|
||
| func TestMergeSubmitOptions_ValidJSON(t *testing.T) { | ||
| baseOptions := []byte(`{"existing":"option","number":42}`) | ||
| signingAddress := "celestia1def456" | ||
|
|
||
| result, err := mergeSubmitOptions(baseOptions, signingAddress) | ||
| require.NoError(t, err) | ||
|
|
||
| var resultMap map[string]interface{} | ||
| err = json.Unmarshal(result, &resultMap) | ||
| require.NoError(t, err) | ||
|
|
||
| assert.Equal(t, "option", resultMap["existing"]) | ||
| assert.Equal(t, float64(42), resultMap["number"]) // JSON numbers are float64 | ||
| assert.Equal(t, signingAddress, resultMap["signer_address"]) | ||
| } | ||
|
|
||
| func TestMergeSubmitOptions_InvalidJSON(t *testing.T) { | ||
| baseOptions := []byte(`not-json-content`) | ||
| signingAddress := "celestia1ghi789" | ||
|
|
||
| result, err := mergeSubmitOptions(baseOptions, signingAddress) | ||
| require.NoError(t, err) | ||
|
|
||
| var resultMap map[string]interface{} | ||
| err = json.Unmarshal(result, &resultMap) | ||
| require.NoError(t, err) | ||
|
|
||
| // Should create new JSON object with just the signing address | ||
| assert.Equal(t, signingAddress, resultMap["signer_address"]) | ||
| assert.Len(t, resultMap, 1, "should only contain signing address when base options are invalid JSON") | ||
| } | ||
|
|
||
| func TestMergeSubmitOptions_OverrideExistingAddress(t *testing.T) { | ||
| baseOptions := []byte(`{"signer_address":"old-address","other":"data"}`) | ||
| newAddress := "celestia1new456" | ||
|
|
||
| result, err := mergeSubmitOptions(baseOptions, newAddress) | ||
| require.NoError(t, err) | ||
|
|
||
| var resultMap map[string]interface{} | ||
| err = json.Unmarshal(result, &resultMap) | ||
| require.NoError(t, err) | ||
|
|
||
| assert.Equal(t, newAddress, resultMap["signer_address"], "should override existing signing address") | ||
| assert.Equal(t, "data", resultMap["other"]) | ||
| } | ||
|
|
||
| func TestMergeSubmitOptions_NilBaseOptions(t *testing.T) { | ||
| signingAddress := "celestia1jkl012" | ||
|
|
||
| result, err := mergeSubmitOptions(nil, signingAddress) | ||
| require.NoError(t, err) | ||
|
|
||
| var resultMap map[string]interface{} | ||
| err = json.Unmarshal(result, &resultMap) | ||
| require.NoError(t, err) | ||
|
|
||
| assert.Equal(t, signingAddress, resultMap["signer_address"]) | ||
| } | ||
|
|
||
| func TestMergeSubmitOptions_ComplexJSON(t *testing.T) { | ||
| baseOptions := []byte(`{ | ||
| "nested": { | ||
| "key": "value" | ||
| }, | ||
| "array": [1, 2, 3], | ||
| "bool": true | ||
| }`) | ||
| signingAddress := "celestia1complex" | ||
|
|
||
| result, err := mergeSubmitOptions(baseOptions, signingAddress) | ||
| require.NoError(t, err) | ||
|
|
||
| var resultMap map[string]interface{} | ||
| err = json.Unmarshal(result, &resultMap) | ||
| require.NoError(t, err) | ||
|
|
||
| // Check nested structure is preserved | ||
| nested, ok := resultMap["nested"].(map[string]interface{}) | ||
| require.True(t, ok) | ||
| assert.Equal(t, "value", nested["key"]) | ||
|
|
||
| // Check array is preserved | ||
| array, ok := resultMap["array"].([]interface{}) | ||
| require.True(t, ok) | ||
| assert.Len(t, array, 3) | ||
|
|
||
| // Check bool is preserved | ||
| assert.Equal(t, true, resultMap["bool"]) | ||
|
|
||
| // Check signing address was added | ||
| assert.Equal(t, signingAddress, resultMap["signer_address"]) | ||
| } | ||
randygrok marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func TestMergeSubmitOptions_NullJSON(t *testing.T) { | ||
| base := []byte("null") | ||
| merged, err := mergeSubmitOptions(base, `{"signer_address": "abc"}`) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, merged) | ||
| require.Contains(t, string(merged), "signer_address") | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.