-
Notifications
You must be signed in to change notification settings - Fork 137
Thiagodeev/fix-fee-limit #819
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 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f6c910c
feat: new U128.ToBigInt() method
thiagodeev a329586
feat: make U128.ToBigInt() method validate max value + tests
thiagodeev 6492f32
test: add TestU128_ToUint64 test for the U64.ToUint64() method
thiagodeev 6db36fa
refactor: update FeeEstToResBoundsMap to accept optional limit options
thiagodeev 0b0c825
test: enhance TestFeeEstToResBoundsMap with fee limit scenarios
thiagodeev 4f325d7
test: fix TestResBoundsMapToOverallFee errors
thiagodeev 54d2c1c
chore: update changelog
thiagodeev 0723177
docs: improve FeeEstToResBoundsMap description
thiagodeev 2dec365
chore: describe the U128.ToBigInt() method in the changelog
thiagodeev b66dbde
feat: new CustomFeeEstToResBoundsMap method
thiagodeev c9edfc4
test: new CustomFeeEstToResBoundsMap test case
thiagodeev f02ada2
chore: update changelog
thiagodeev 095b7ee
chore: implement PR comments observations
thiagodeev 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,109 @@ | ||
| package rpc_test | ||
|
|
||
| import ( | ||
| "math" | ||
| "math/big" | ||
| "testing" | ||
|
|
||
| internalUtils "github.com/NethermindEth/starknet.go/internal/utils" | ||
| "github.com/NethermindEth/starknet.go/rpc" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| // TestU128_ToBigInt tests the ToBigInt method of the U128 type. | ||
| func TestU128_ToBigInt(t *testing.T) { | ||
| tests := []struct { | ||
| name string // description of this test case | ||
| u128 rpc.U128 | ||
| want *big.Int | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "within the range", | ||
| u128: "0xabcdef", | ||
| want: internalUtils.HexToBN("0xabcdef"), | ||
| }, | ||
| { | ||
| name: "max uint128", | ||
| u128: "0xffffffffffffffffffffffffffffffff", | ||
| want: internalUtils.HexToBN("0xffffffffffffffffffffffffffffffff"), | ||
| }, | ||
| { | ||
| name: "out of range", | ||
| u128: "0x100000000000000000000000000000000", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid hex string", | ||
| u128: "56yrty45", | ||
| wantErr: true, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| u := tt.u128 | ||
| got, gotErr := u.ToBigInt() | ||
| if gotErr != nil { | ||
| if !tt.wantErr { | ||
| t.Errorf("ToBigInt() failed: %v", gotErr) | ||
| } | ||
|
|
||
| return | ||
| } | ||
| if tt.wantErr { | ||
| t.Fatal("ToBigInt() succeeded unexpectedly") | ||
| } | ||
|
|
||
| assert.Equal(t, tt.want, got) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // TestU128_ToUint64 tests the ToUint64 method of the U128 type. | ||
| func TestU128_ToUint64(t *testing.T) { | ||
| tests := []struct { | ||
| name string // description of this test case | ||
| u64 rpc.U64 | ||
| want uint64 | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "within the range", | ||
| u64: "0xabcdef", | ||
| want: 11259375, | ||
| }, | ||
| { | ||
| name: "max uint64", | ||
| u64: "0xFFFFFFFFFFFFFFFF", | ||
| want: math.MaxUint64, | ||
| }, | ||
| { | ||
| name: "out of range", | ||
| u64: "0x10000000000000000", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid hex string", | ||
| u64: "56yrty45", | ||
| wantErr: true, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| u := tt.u64 | ||
| got, gotErr := u.ToUint64() | ||
| if gotErr != nil { | ||
| if !tt.wantErr { | ||
| t.Errorf("ToUint64() failed: %v", gotErr) | ||
| } | ||
|
|
||
| return | ||
| } | ||
| if tt.wantErr { | ||
| t.Fatal("ToUint64() succeeded unexpectedly") | ||
| } | ||
|
|
||
| assert.Equal(t, tt.want, got) | ||
| }) | ||
| } | ||
| } |
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
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.