• protolambda's avatar
    op-chain-ops: source maps fixes + FS (#11574) · 36279371
    protolambda authored
    * op-chain-ops: source maps fixes + FS
    
    * op-chain-ops/srcmap: add doc-comment, remove replaced test
    
    * op-chain-ops: address review comments
    
    * op-chain-ops: fix missing .sol extension
    
    * op-chain-ops: fix artifacts traversal; check extension again, just don't trim the extension
    36279371
sourcefs_test.go 779 Bytes
package foundry

import (
	"os"
	"testing"

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

//go:generate ./testdata/srcmaps/generate.sh

func TestSourceMapFS(t *testing.T) {
	artifactFS := OpenArtifactsDir("./testdata/srcmaps/test-artifacts")
	exampleArtifact, err := artifactFS.ReadArtifact("SimpleStorage.sol", "SimpleStorage")
	require.NoError(t, err)
	srcFS := NewSourceMapFS(os.DirFS("./testdata/srcmaps"))
	srcMap, err := srcFS.SourceMap(exampleArtifact, "SimpleStorage")
	require.NoError(t, err)
	seenInfo := make(map[string]struct{})
	for i := range exampleArtifact.DeployedBytecode.Object {
		seenInfo[srcMap.FormattedInfo(uint64(i))] = struct{}{}
	}
	require.Contains(t, seenInfo, "src/SimpleStorage.sol:11:5")
	require.Contains(t, seenInfo, "src/StorageLibrary.sol:8:9")
}