Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions op-bindings/bindgen/fixtures_bytecode_test.go

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions op-bindings/bindgen/fixtures_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

// The Init bytecode used for these tests can either be sourced
// on-chain using the deployment tx of these contracts, or can be
// found in the bindings output from BindGen (../bindings/)
var removeDeploymentSaltTests = []struct {
name string
deploymentData string
deploymentSalt string
expected string
}{
{
"TestRemoveDeploymentSalt Case #1",
Safe_v130InitBytecode,
"0000000000000000000000000000000000000000000000000000000000000000",
Safe_v130InitBytecodeNoSalt,
},
{
"TestRemoveDeploymentSalt Case #2",
Permit2InitBytecode,
"0000000000000000000000000000000000000000d3af2663da51c10215000000",
Permit2InitBytecodeNoSalt,
},
{
"TestRemoveDeploymentSalt Case #3",
EntryPointInitBytecode,
"0000000000000000000000000000000000000000000000000000000000000000",
EntryPointInitBytecodeNoSalt,
},
}

var removeDeploymentSaltTestsFailures = []struct {
name string
deploymentData string
deploymentSalt string
expectedError string
}{
{
"TestRemoveDeploymentSalt Failure Case #1 Invalid Regex",
"0x1234abc",
"[invalid-regex",
"failed to compile regular expression: error parsing regexp: missing closing ]: `[invalid-regex)`",
},
{
"TestRemoveDeploymentSalt Failure Case #2 Salt Not Found",
"0x1234abc",
"4567",
"expected salt: 4567 to be at the beginning of the contract initialization code: 0x1234abc, but it wasn't",
},
}
29 changes: 29 additions & 0 deletions op-bindings/bindgen/remote_handlers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestRemoveDeploymentSalt(t *testing.T) {
generator := bindGenGeneratorRemote{}

for _, tt := range removeDeploymentSaltTests {
t.Run(tt.name, func(t *testing.T) {
got, _ := generator.removeDeploymentSalt(tt.deploymentData, tt.deploymentSalt)
require.Equal(t, tt.expected, got)
})
}
}

func TestRemoveDeploymentSaltFailures(t *testing.T) {
generator := bindGenGeneratorRemote{}

for _, tt := range removeDeploymentSaltTestsFailures {
t.Run(tt.name, func(t *testing.T) {
_, err := generator.removeDeploymentSalt(tt.deploymentData, tt.deploymentSalt)
require.Equal(t, err.Error(), tt.expectedError)
})
}
}