Commit graph

7625 commits

Author SHA1 Message Date
Roman Khimov
86faf7b343 rpcsrv: close idle client connections in doRPCCallOverHTTP
Shouldn't affect things much, yet at the same time we no longer need any
connection after we're done with the request.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-13 12:58:15 +03:00
Anna Shaleva
319880e201
Merge pull request #3340 from nspcc-dev/wsclient-test
rpcclient: fix TestWSClientNonBlockingEvents
2024-03-13 12:08:11 +03:00
Ekaterina Pavlova
0016b6b630 rpc: add synchronisation for httptest.Server in tests
Add waiting for startSending to ensure that the client is ready before
the server starts sending messages.

Close #3005
Close #3312

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-13 11:41:43 +03:00
Anna Shaleva
b12ef701f0
Merge pull request #3344 from nspcc-dev/concurrent-test
rpcsrv: fix concurrent test TestClient_IteratorSessions
2024-03-12 00:04:31 +03:00
Ekaterina Pavlova
588d7c6418 rpcsrv: fix concurrent test TestClient_IteratorSessions
The default for `MaxConnsPerHost` is "no limit", so it'll use as many
connections as it can (potentially hitting MacOS/Windows limits
https://github.com/golang/go/issues/20960#issuecomment-447918270 ).

Close #3300

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-11 22:00:23 +03:00
Anna Shaleva
0e47d662b5
Merge pull request #3347 from nspcc-dev/inc-test-timeout
workflows: give tests more time
2024-03-11 10:38:15 +03:00
Roman Khimov
54c53cf6ca workflows: give tests more time
We have more and more timeouts happening for test runs, so 10m is not enough
for busy GH machines sometime. I think we can just give them a bit more time.

Refs. #2379 though.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-09 14:34:40 +03:00
Roman Khimov
025bf228a2
Merge pull request #3335 from nspcc-dev/TestFailedPreconditionShutdown
rpcsrv: fix TestFailedPreconditionShutdown shutdown
2024-03-06 10:24:30 +03:00
Anna Shaleva
bdcc036073
Merge pull request #3339 from nspcc-dev/workaround-coverage
workflows: workaround Go 1.22 coverage problem
2024-03-06 10:15:58 +03:00
Roman Khimov
d31b01d4b1 workflows: workaround Go 1.22 coverage problem
See https://github.com/golang/go/issues/65653, the fix can be postponed up
to Go 1.23 and we need green.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-06 10:03:02 +03:00
Ekaterina Pavlova
ee39b5ca18 rpcsrv: add close of http server in tests
The HTTP server should be closed at the end of the test.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-06 01:17:59 +03:00
Ekaterina Pavlova
46f2da0fb1 rpcsrv: add close of blockchain and rpc server in tests
The logs race issue is a result of improper shutdown during testing.

Close #3217

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-03-06 01:17:59 +03:00
Roman Khimov
b7efccc040
Merge pull request #3333 from nspcc-dev/upd-go-ordered-js
go.mod: better go-ordered-json
2024-03-05 19:29:05 +03:00
Anna Shaleva
a256eac619
Merge pull request #3337 from nspcc-dev/fix-notary-test
notary: fix "Condition never satisfied" in Notary test, fix #2422
2024-03-05 19:11:59 +03:00
Anna Shaleva
261b389e24 go.mod: better go-ordered-json
Almost no functional changes, the most important one is that virtuald
dependency is removed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 19:05:32 +03:00
Anna Shaleva
9e99e35a63
Merge pull request #3338 from nspcc-dev/dep-up
Dependency update
2024-03-05 19:03:28 +03:00
Roman Khimov
b2936e602c notary: fix getCompletedTx error
It checks for any transaction given (like fb), not exactly the main one.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 19:01:03 +03:00
Roman Khimov
d65b1fd66d *: use v2 LRU, fix #3322
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 18:39:17 +03:00
Roman Khimov
72ebcbec72 go.mod: update all external dependencies
Except for github.com/urfave/cli which breaks the CLI if upgraded to v1.22.14.
Refs. #3097.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 18:38:29 +03:00
Roman Khimov
d2a7162217 notary: fix "Condition never satisfied" in Notary test, fix #2422
The theory is:
 * we add a block
 * it triggers notary
 * which can process the fallback before we're to setFinalizeWithError
 * it'll fail and require an additional block to enter, but it's never added
 * FAIL

The solution is:
 * always add an additional block, but treat the first fb specially

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-03-05 18:09:25 +03:00
Roman Khimov
49edf9e498
Merge pull request #3336 from nspcc-dev/go-upd
Add Go 1.22 support, drop Go 1.19 support
2024-03-05 15:40:02 +03:00
Anna Shaleva
8162e9033d *: replace slice.Copy with bytes.Clone
And refactor some code a bit, don't use bytes.Clone where type-specific
helpers may be used instead.

Close #2907.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
b030c331b0 core: copy SC storage iterator prefix while returning values
It's a bug since Prefix is shared between all iterator items and
appending is not enough. If prefix has enough capacity, then new slice
won't be created and the previous item's prefix will be changed.

This commit fixes the following test failure caused by moving from
bytes.Clone to slice.Copy:
```
 --- FAIL: TestComlileAndInvokeFunction/test_Storage.Find (0.02s)
        --- FAIL: TestComlileAndInvokeFunction/test_Storage.Find/keys_only (0.01s)
            contract_test.go:866:
                	Error Trace:	/home/anna/Documents/GitProjects/nspcc-dev/neo-go/cli/smartcontract/contract_test.go:866
                	Error:      	Not equal:
                	            	expected: []stackitem.Item{(*stackitem.ByteArray)(0xc000a1cdf8), (*stackitem.ByteArray)(0xc000a1ce10)}
                	            	actual  : []stackitem.Item{(*stackitem.ByteArray)(0xc000a1cdb0), (*stackitem.ByteArray)(0xc000a1cdc8)}

                	            	Diff:
                	            	--- Expected
                	            	+++ Actual
                	            	@@ -2,3 +2,3 @@
                	            	  (*stackitem.ByteArray)((len=8) {
                	            	-  00000000  66 69 6e 64 6b 65 79 31                           |findkey1|
                	            	+  00000000  66 69 6e 64 6b 65 79 32                           |findkey2|
                	            	  }),
                	Test:       	TestComlileAndInvokeFunction/test_Storage.Find/keys_only
        --- FAIL: TestComlileAndInvokeFunction/test_Storage.Find/both (0.01s)
            contract_test.go:881:
                	Error Trace:	/home/anna/Documents/GitProjects/nspcc-dev/neo-go/cli/smartcontract/contract_test.go:881
                	Error:      	Not equal:
                	            	expected: []stackitem.Item{(*stackitem.ByteArray)(0xc000515920), (*stackitem.ByteArray)(0xc000515938)}
                	            	actual  : []stackitem.Item{(*stackitem.ByteArray)(0xc000515848), (*stackitem.ByteArray)(0xc000515860)}

                	            	Diff:
                	            	--- Expected
                	            	+++ Actual
                	            	@@ -2,3 +2,3 @@
                	            	  (*stackitem.ByteArray)((len=8) {
                	            	-  00000000  66 69 6e 64 6b 65 79 31                           |findkey1|
                	            	+  00000000  66 69 6e 64 6b 65 79 32                           |findkey2|
                	            	  }),
                	Test:       	TestComlileAndInvokeFunction/test_Storage.Find/both
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
1560df6913 *: add nolint comment to deprecated math/rand usages
They are used in tests only.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
0c6627f13d *: use multierror wrapping where possible
Revert 5f6c01336c, remove all multierror
related nolint comments and use multierror wrapping instead.

Close #2906.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
13ff95a3d3 go.mod: upgrade minimum required Go version to 1.20
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
5485cf60da Dockerfile: switch to Go 1.22 based images
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:53:58 +03:00
Anna Shaleva
3f772c2711 workflows: use newer Go 1.22, drop Go 1.19
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 11:43:23 +03:00
Anna Shaleva
c660a6e8f3 workflows: remove cache argument from setup-go action
`actions/setup-go@v5` doesn't have `cache` argument.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 11:43:23 +03:00
Anna Shaleva
90db72abc9 workflows: upgrade runners
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 11:42:53 +03:00
Roman Khimov
8d67f17943
Merge pull request #3332 from nspcc-dev/fix-nep17-test
cli: fix race in TestNEP17Balance
2024-03-03 15:27:25 +03:00
Anna Shaleva
46a3ff3348 *: regenerate all wallets with adjusted parameters
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:03 +03:00
Anna Shaleva
9525bc7785 wallet: fix scrypt parameters in wallet regeneration tests
Default NEP2 scrypt parameters should be overriden where needed,
otherwise our regeneration tests won't generate proper wallets.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:03 +03:00
Anna Shaleva
685d095fa4 cli: fix race in TestNEP17Balance
`wallet1_solo.json` can't be used in this test because it contains
committee member that receives reward for accepted blocks. The race in
this test happens due to the  fact that it uses running blockchain and
checks expected GAS balance via call to blockchain's
GetUtilityTokenBalance API. This call is racy with the CLI command
executed prior to the call which causes the following test failure:
```
2023-04-06T08:44:08.6038406Z === NAME  TestNEP17Balance/all_accounts
2023-04-06T08:44:08.6038738Z     executor.go:240:
2023-04-06T08:44:08.6039454Z         	Error Trace:	/opt/github-runner/_work/neo-go/neo-go/cli/nep_test/executor.go:240
2023-04-06T08:44:08.6040628Z         	            				/opt/github-runner/_work/neo-go/neo-go/cli/nep_test/executor.go:236
2023-04-06T08:44:08.6041787Z         	            				/opt/github-runner/_work/neo-go/neo-go/cli/nep_test/nep17_test.go:73
2023-04-06T08:44:08.6042389Z         	Error:      	Expect "	Amount : 1" to match "^\s*Amount\s*:\s*1.5$"
2023-04-06T08:44:08.6042865Z         	Test:       	TestNEP17Balance/all_accounts
```

The fix is do not use committee accounts for balance checks. Let's use
side accounts and transfer funds to some of them before the test start.
Close #2960.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:02 +03:00
Anna Shaleva
1f4e1922ee cli: add new testing wallet
It contains several simple signature accounts that are not related to
network committee or validators. Needed for tests, existing
`testwallet.json` can't de reused since some tests need testing wallet
with a single account.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-29 23:48:10 +03:00
Roman Khimov
2404145133
Merge pull request #3331 from nspcc-dev/upd-go-ordered-json
go.mod: upgrade go-ordered-json
2024-02-29 13:36:32 +03:00
Anna Shaleva
e1e2b5304f go.mod: upgrade go-ordered-json
Fetch C# node compatibility fixes for the rest of corner cases. Ref.
https://github.com/nspcc-dev/go-ordered-json/pull/11.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-29 13:31:06 +03:00
Roman Khimov
9d7357c9fd
Merge pull request #3329 from nspcc-dev/support-rpc-maps 2024-02-28 16:26:29 +03:00
Anna Shaleva
132531fabe rpcsrv: support Map parameter in invokefunction RPC handler
We have smartcontract.ParameterPair structure that can be properly
marshalled and passed to RPC server as an element of smartcontract.Map
structure. However, RPC server can't unmarshal map values properly
without this change.

This change is compatible with C# node.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-28 15:54:33 +03:00
Anna Shaleva
6a560b9a95
Merge pull request #3330 from nspcc-dev/add-macos
Add ARM-based MacOS tests
2024-02-28 12:39:17 +03:00
Roman Khimov
630bd29b8d workflows: drop manual go mod downloads
It's done automatically since like forever, these steps are useless.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-28 12:09:15 +03:00
Roman Khimov
5fcae176b8 workflows: add MacOS 14 runner for tests
It's ARM-based, so it's a very nice combination.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-02-28 12:08:13 +03:00
Roman Khimov
cc38221d77
Merge pull request #3307 from nspcc-dev/test-register-peers
services: fix logging data race after shutdown
2024-02-27 17:09:08 +03:00
Ekaterina Pavlova
5cf0c75744 network: fix server shutdown by waiting for goroutines to finish
s.Shutdown() does not wait for all goroutines of the node server to
finish normally just because the server exits without dependent
goroutines awaiting. Which causes logs to attempt to write after the
test has ended. The consequence of this bug fix is that corresponding
tests are fixed.

Close #2973
Close #2974

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
5bb7c6b715 services: update logs flush after services shutdown
Added sync logs for every service separately to provide the ability to
have a custom logger for each service. This commit makes the code follow
the zap usages rules: `Sync calls the underlying Core's Sync method,
flushing any buffered log entries. Applications should take care to
call Sync before exiting.`

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
9b540770cd network: fix typo
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
775c56e87e network: ensure server is started and shut down only once
Use started atomic.Bool field to ensure that the node server shutdown
procedure is executed only once. Prevent the following panic caused by
server double-shutdown in testing code:
```
--- FAIL: TestServerRegisterPeer (0
.06s)
 panic: closed twice
 goroutine 60 [running]:
 testing.tRunner.func1.2({0x104c40b20, 0x104d0ec90})
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1545 +0x1c8
 testing.tRunner.func1()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1548 +0x360
 panic({0x104c40b20?, 0x104d0ec90?})
 	/opt/homebrew/opt/go/libexec/src/runtime/panic.go:914 +0x218
 github.com/nspcc-dev/neo-go/pkg/network.(*fakeTransp).Close
 (0x14000159e08?)
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network
 	/discovery_test.go:83 +0x54
 github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown
 (0x14000343400)
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network/server.go:299
 	 +0x104
 github.com/nspcc-dev/neo-go/pkg/network.startWithCleanup.func1()
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network/server_test
 	.go:408 +0x20
 testing.(*common).Cleanup.func1()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1169 +0x110
 testing.(*common).runCleanup(0x1400032c340, 0x14000159d80?)
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1347 +0xd8
 testing.tRunner.func2()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1589 +0x2c
 testing.tRunner(0x1400032c340, 0x104d0c5d0)
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1601 +0x114
 created by testing.(*T).Run in goroutine 1
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1648 +0x33c
```

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
4715e523e0 services: move blockchain/mempool subscriptions to separate routine
Start of some services is bound to blockchain subscriptions, and thus,
can't be run before the blockchain notifications dispatcher.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Ekaterina Pavlova
f8dc5ec44f network: change server Start() behavior
Previously user should Start server in a separate goroutine. Now
separate goroutine is created inside the Start(). For normal server
operation, the caller should wait for Start to finish. Also, fixed
TestTryInitStateSync test which was exiting earlier than logs are
called.

Close #3112

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-02-27 15:10:51 +03:00
Roman Khimov
224808975b
Merge pull request #3328 from nspcc-dev/mod-upd
.github: use minimum required Go version from go.mod
2024-02-27 14:02:42 +03:00