0chain / gosdk

A client SDK in Go to interface the blockchain and storage platform, and other smart contracts
MIT License
32 stars 29 forks source link

[FLAKY] snapshot unit test fails sometimes because of index out of bounds #767

Closed aniketsingh03 closed 1 year ago

aniketsingh03 commented 1 year ago

TestGetAggregates in zcncore/sample/snapshot_test.go is showing a flaky behaviour. Following stacktrace is seen which goes away on retriggering multiple times:

panic: reflect: slice length out of range in SetLen

goroutine 45 [running]:
reflect.Value.SetLen({0x81cfa0?, 0xc0003040d8?, 0x0?}, 0xe)
    /root/docker-build-actions-runner/_work/_tool/go/1.18.10/x64/src/reflect/value.go:2188 +0x8d
encoding/json.(*decodeState).array(0xc0003da360, {0x813940?, 0xc0003040d8?, 0x0?})
    /root/docker-build-actions-runner/_work/_tool/go/1.18.10/x64/src/encoding/json/decode.go:555 +0x5cd
encoding/json.(*decodeState).value(0xc0003da360, {0x813940?, 0xc0003040d8?, 0x90?})
    /root/docker-build-actions-runner/_work/_tool/go/1.18.10/x64/src/encoding/json/decode.go:363 +0x7e
encoding/json.(*decodeState).unmarshal(0xc0003da360, {0x813940?, 0xc0003040d8?})
    /root/docker-build-actions-runner/_work/_tool/go/1.18.10/x64/src/encoding/json/decode.go:180 +0x1de
encoding/json.Unmarshal({0xc00036b300, 0x11fd, 0x1300}, {0x813940, 0xc0003040d8})
    /root/docker-build-actions-runner/_work/_tool/go/1.18.10/x64/src/encoding/json/decode.go:107 +0x125
github.com/0chain/gosdk/zcnbridge/wallet.(*ZCNStatus).OnInfoAvailable(0xc000316000, 0xc000421500?, 0x11fd?, {0xc000204c00?, 0x70?}, {0x0?, 0x0?})
    /root/docker-build-actions-runner/_work/gosdk/gosdk/zcnbridge/wallet/status.go:98 +0x107
github.com/0chain/gosdk/zcncore.GetInfoFromAnySharder({0xc00012a070, 0x70}, 0x0?, {0x9fcbc0, 0xc000316000})
    /root/docker-build-actions-runner/_work/gosdk/gosdk/zcncore/transaction_query_base.go:537 +0x24e
created by github.com/0chain/gosdk/zcncore.GetUserSnapshots
    /root/docker-build-actions-runner/_work/gosdk/gosdk/zcncore/wallet_base.go:1129 +0x1b1
FAIL    github.com/0chain/gosdk/zcncore/sample  0.417s
?       github.com/0chain/gosdk/zcnswap [no test files]
?       github.com/0chain/gosdk/zcnswap/config  [no test files]
?       github.com/0chain/gosdk/zcnswap/contracts   [no test files]
?       github.com/0chain/gosdk/zcnswap/swapfactory [no test files]
?       github.com/0chain/gosdk/zcnswap/swapfactory/bancor  [no test files]
?       github.com/0chain/gosdk/zcnswap/swapfactory/erc20   [no test files]
=== RUN   TestEthUtils
=== RUN   TestEthUtils/Correct_percentage
--- PASS: TestEthUtils (0.00s)
    --- PASS: TestEthUtils/Correct_percentage (0.00s)
dabasov commented 1 year ago

I believe it is not unit test and more like learning test, it should be Skipped normally