Closed huahuayu closed 1 year ago
After some dig, I found there are two issues:
HTTPAddr()
get the container's ip address but it can be accessed from the host func (t *TestServer) HTTPAddr() string {
return fmt.Sprintf("http://%s:8545", t.resource.Container.NetworkSettings.IPAddress)
}
I changed it to localhost with binding port then it's ok
func (t *TestServer) HTTPAddr() string {
port := t.resource.GetPort("8545/tcp")
return fmt.Sprintf("http://localhost:%s", port)
}
Now the tests can be run but some tests failed, FYI
GOROOT=/usr/local/go #gosetup
GOPATH=/Users/shiming/go #gosetup
/usr/local/go/bin/go test -c -o /private/var/folders/z4/sqccl7ys2yjbj3qrjl62q45m0000gn/T/GoLand/___1TestEncoding_in_github_com_umbracle_ethgo_abi.test -gcflags all=-N -l github.com/umbracle/ethgo/abi #gosetup
/usr/local/go/bin/go tool test2json -t /private/var/folders/z4/sqccl7ys2yjbj3qrjl62q45m0000gn/T/dlvLauncher.sh /Applications/GoLand.app/Contents/plugins/go/lib/dlv/macarm/dlv --listen=127.0.0.1:55297 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /private/var/folders/z4/sqccl7ys2yjbj3qrjl62q45m0000gn/T/GoLand/___1TestEncoding_in_github_com_umbracle_ethgo_abi.test -- -test.v -test.paniconexit0 -test.run ^\QTestEncoding\E$
=== RUN TestEncoding
[]
--- FAIL: TestEncoding (5.09s)
=== RUN TestEncoding/#00
--- PASS: TestEncoding/#00 (0.00s)
=== RUN TestEncoding/#01
--- PASS: TestEncoding/#01 (0.00s)
=== RUN TestEncoding/#02
--- PASS: TestEncoding/#02 (0.00s)
=== RUN TestEncoding/#03
--- PASS: TestEncoding/#03 (0.00s)
=== RUN TestEncoding/#04
--- PASS: TestEncoding/#04 (0.00s)
=== RUN TestEncoding/#05
--- PASS: TestEncoding/#05 (0.00s)
=== RUN TestEncoding/#06
--- PASS: TestEncoding/#06 (0.00s)
=== RUN TestEncoding/#07
--- PASS: TestEncoding/#07 (0.00s)
=== RUN TestEncoding/#08
--- PASS: TestEncoding/#08 (0.00s)
=== RUN TestEncoding/#09
--- PASS: TestEncoding/#09 (0.00s)
=== RUN TestEncoding/#10
--- PASS: TestEncoding/#10 (0.00s)
=== RUN TestEncoding/#11
--- PASS: TestEncoding/#11 (0.00s)
=== RUN TestEncoding/#12
--- PASS: TestEncoding/#12 (0.00s)
=== RUN TestEncoding/#13
--- PASS: TestEncoding/#13 (0.00s)
=== RUN TestEncoding/#14
--- PASS: TestEncoding/#14 (0.00s)
=== RUN TestEncoding/#15
--- PASS: TestEncoding/#15 (0.00s)
=== RUN TestEncoding/#16
--- PASS: TestEncoding/#16 (0.00s)
=== RUN TestEncoding/#17
--- PASS: TestEncoding/#17 (0.00s)
=== RUN TestEncoding/#18
--- PASS: TestEncoding/#18 (0.00s)
=== RUN TestEncoding/#19
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#19 (0.00s)
=== RUN TestEncoding/#20
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#20 (0.00s)
=== RUN TestEncoding/#21
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#21 (0.00s)
=== RUN TestEncoding/#22
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#22 (0.00s)
=== RUN TestEncoding/#23
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#23 (0.00s)
=== RUN TestEncoding/#24
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#24 (0.00s)
=== RUN TestEncoding/#25
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#25 (0.00s)
=== RUN TestEncoding/#26
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#26 (0.00s)
=== RUN TestEncoding/#27
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#27 (0.00s)
=== RUN TestEncoding/#28
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#28 (0.00s)
=== RUN TestEncoding/#29
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#29 (0.00s)
=== RUN TestEncoding/#30
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#30 (0.00s)
=== RUN TestEncoding/#31
--- PASS: TestEncoding/#31 (0.00s)
=== RUN TestEncoding/#32
--- PASS: TestEncoding/#32 (0.00s)
=== RUN TestEncoding/#33
--- PASS: TestEncoding/#33 (0.00s)
=== RUN TestEncoding/#34
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#34 (0.00s)
=== RUN TestEncoding/#35
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#35 (0.00s)
=== RUN TestEncoding/#36
--- PASS: TestEncoding/#36 (0.00s)
=== RUN TestEncoding/#37
encoding_test.go:328: failed to compile:
--- FAIL: TestEncoding/#37 (0.00s)
FAIL
Debugger finished with the exit code 0
This has been fixed in another way, instead of relying on a custom server for each test (which requires dealing with nuances from MacOs and Linux), there is a helper bash script that deploys the blockchain at startup. Now, the test cannot rely on an independent and isolated environment for the execution but it is easier to scale and remove these issues.
Env
Mac m1 macos 12.4 Docker Desktop 4.10.1
Issue
When run
abi/encoding_test.go/TestEncoding(t *testing.T)
functionThe
testsuit/server.go
NewTestServer()
created a geth client, but port 8545 can't be reached.Error screenshot
The docker container info
Inside the container the command is
I think it's because of the wrong geth command, it's actually equivalent to using blew
docker-compose.yml
to start a geth client, the container can get up, but inside the container, telnet 127.0.0.1 8545, doesn't work.