Skip to content

Commit

Permalink
Pull in ffcommon, reinstate scientific numbers
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
  • Loading branch information
matthew1001 committed Sep 3, 2024
1 parent bad89ec commit 40ef535
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/hyperledger/firefly-signer => github.com/kaleido-io/firefly-signer v0.0.0-20240827135812-3c6f71cfc108
replace github.com/hyperledger/firefly-signer => github.com/kaleido-io/firefly-signer v0.0.0-20240827145609-70863b71eb78

replace github.com/hyperledger/firefly-common => github.com/kaleido-io/firefly-common v0.0.0-20240827134901-edb07289f156
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kaleido-io/firefly-common v0.0.0-20240827134901-edb07289f156 h1:HQpScPoAm9xsACbu9r31wVQ5sQFxLsfe9XzPGY5c4rI=
github.com/kaleido-io/firefly-common v0.0.0-20240827134901-edb07289f156/go.mod h1:dXewcVMFNON2SvQ1UPvu64OWUt77+M3p8qy61lT1kE4=
github.com/kaleido-io/firefly-signer v0.0.0-20240827135812-3c6f71cfc108 h1:Vix70J+rkeInHxhl3evmLij4QhE33zo6GCgaB2ZLp8c=
github.com/kaleido-io/firefly-signer v0.0.0-20240827135812-3c6f71cfc108/go.mod h1:Xj2PF6y8Ce26jX38ch0KasNnnZCSyzcwyLSv8NN+7JA=
github.com/kaleido-io/firefly-signer v0.0.0-20240827145609-70863b71eb78 h1:KVn6azO0KM9NH6+SYktI3Lh8AyQXutYdMb45lZXO+Uc=
github.com/kaleido-io/firefly-signer v0.0.0-20240827145609-70863b71eb78/go.mod h1:Xj2PF6y8Ce26jX38ch0KasNnnZCSyzcwyLSv8NN+7JA=
github.com/karlseguin/ccache v2.0.3+incompatible h1:j68C9tWOROiOLWTS/kCGg9IcJG+ACqn5+0+t8Oh83UU=
github.com/karlseguin/ccache v2.0.3+incompatible/go.mod h1:CM9tNPzT6EdRh14+jiW8mEF9mkNZuuE51qmgGYUB93w=
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
Expand Down
49 changes: 49 additions & 0 deletions internal/ethereum/deploy_contract_prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ const samplePrepareDeployTXLargeInputParams = `{
"params": [ 10000000000000000000000001, "some-text" ]
}`

const samplePrepareDeployTXScientificNotation = `{
"ffcapi": {
"version": "v1.0.0",
"id": "904F177C-C790-4B01-BDF4-F2B4E52E607E",
"type": "DeployContract"
},
"from": "0xb480F96c0a3d6E9e9a263e4665a39bFa6c4d01E8",
"to": "0xe1a078b9e2b145d0a7387f09277c6ae1d9470771",
"gas": 1000000,
"nonce": "111",
"value": "12345678901234567890123456789",
"contract": "0xdeadbeef",
"definition": [{
"inputs": [
{
"internalType":" uint256",
"name": "x",
"type": "uint256"
},
{
"internalType":" string",
"name": "y",
"type": "string"
}
],
"outputs":[],
"type":"constructor"
}],
"params": [ 1.0000000000000000000000001e+25, "some-text" ]
}`

func TestDeployContractPrepareOkNoEstimate(t *testing.T) {

ctx, c, _, done := newTestConnector(t)
Expand Down Expand Up @@ -136,6 +167,24 @@ func TestDeployContractPrepareOkLargeInputParam(t *testing.T) {
assert.True(t, strings.Contains(res.TransactionData, "736f6d652d74657874"))
}

func TestDeployContractPrepareOkScientificNotationParam(t *testing.T) {

ctx, c, _, done := newTestConnector(t)
defer done()

var req ffcapi.ContractDeployPrepareRequest
err := json.Unmarshal([]byte(samplePrepareDeployTXScientificNotation), &req)
assert.NoError(t, err)
res, reason, err := c.DeployContractPrepare(ctx, &req)
assert.NoError(t, err)
assert.Empty(t, reason)
assert.Equal(t, int64(1000000), res.Gas.Int64())
// Basic check that our input param 1.0000000000000000000000001e+25 is in the TX data
assert.True(t, strings.Contains(res.TransactionData, "84595161401484a000001"))
// Basic check that our input param "some-text" is in the TX data
assert.True(t, strings.Contains(res.TransactionData, "736f6d652d74657874"))
}

func TestDeployContractPrepareWithEstimateRevert(t *testing.T) {

ctx, c, mRPC, done := newTestConnector(t)
Expand Down

0 comments on commit 40ef535

Please sign in to comment.