generated from flashbots/flashbots-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add min-bid feature * Add Float to U256 test, other minor review changes * Re-wrote floatEthTo256Wei + addressed review comments * Apply suggestions from jtraglia's code review Co-authored-by: Justin Traglia <[email protected]> * fix typo * Changed default min-bid to 0 and added logging Co-authored-by: allboxes <[email protected]> Co-authored-by: Justin Traglia <[email protected]>
- Loading branch information
1 parent
909e004
commit dd4665d
Showing
4 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,36 @@ | ||
package cli | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/flashbots/go-boost-utils/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFloatEthTo256Wei(t *testing.T) { | ||
// test with small input | ||
i := 0.000000000000012345 | ||
weiU256, err := floatEthTo256Wei(i) | ||
require.NoError(t, err) | ||
require.Equal(t, types.IntToU256(12345), *weiU256) | ||
|
||
// test with zero | ||
i = 0 | ||
weiU256, err = floatEthTo256Wei(i) | ||
require.NoError(t, err) | ||
require.Equal(t, types.IntToU256(0), *weiU256) | ||
|
||
// test with large input | ||
i = 987654.3 | ||
weiU256, err = floatEthTo256Wei(i) | ||
require.NoError(t, err) | ||
|
||
r := big.NewInt(9876543) | ||
r.Mul(r, big.NewInt(1e17)) | ||
referenceWeiU256 := new(types.U256Str) | ||
err = referenceWeiU256.FromBig(r) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, *referenceWeiU256, *weiU256) | ||
} |
This file contains 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 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