test: pre-test
	go test -v ./...

cannon-prestate:
	make -C .. cannon-prestate

# We depend on the absolute pre-state generated by cannon to deploy the dispute game contracts.
devnet-allocs: pre-test-cannon
	make -C .. devnet-allocs

pre-test: pre-test-cannon pre-test-allocs


pre-test-cannon:
	@if [ ! -e ../op-program/bin ]; then \
		make cannon-prestate; \
	fi

pre-test-allocs: 
	@if [ ! -e ../.devnet ]; then \
		make devnet-allocs; \
	fi

clean:
	rm -r ../.devnet
	rm -r ../op-program/bin

lint:
	golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...

test-external-%: pre-test
	make -C ./external_$*/
	go test -v --externalL2 ./external_$*/shim


.PHONY: \
	test \
	lint
