solutil_test.go 924 Bytes
Newer Older
1 2 3
package srcmap

import (
clabby's avatar
clabby committed
4
	"path"
5 6 7 8 9 10 11 12 13 14
	"strings"
	"testing"

	"github.com/ethereum/go-ethereum/common/hexutil"
	"github.com/stretchr/testify/require"

	"github.com/ethereum-optimism/optimism/op-bindings/bindings"
)

func TestSourcemap(t *testing.T) {
clabby's avatar
clabby committed
15 16
	t.Skip("TODO(clabby): This test is disabled until source IDs have been added to foundry artifacts.")

clabby's avatar
clabby committed
17
	contractsDir := "../../packages/contracts-bedrock"
clabby's avatar
clabby committed
18
	sources := []string{path.Join(contractsDir, "src/cannon/MIPS.sol")}
clabby's avatar
clabby committed
19
	for i, source := range sources {
clabby's avatar
clabby committed
20
		sources[i] = path.Join(contractsDir, source)
clabby's avatar
clabby committed
21 22
	}

23 24
	deployedByteCode := hexutil.MustDecode(bindings.MIPSDeployedBin)
	srcMap, err := ParseSourceMap(
clabby's avatar
clabby committed
25
		sources,
26 27 28 29 30 31
		deployedByteCode,
		bindings.MIPSDeployedSourceMap)
	require.NoError(t, err)

	for i := 0; i < len(deployedByteCode); i++ {
		info := srcMap.FormattedInfo(uint64(i))
32
		if strings.HasPrefix(info, "unknown") {
33 34 35 36
			t.Fatalf("unexpected info: %q", info)
		}
	}
}