Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync master with feature-flip-204 #5057

Merged
Changes from 1 commit
Commits
Show all changes
487 commits
Select commit Hold shift + click to select a range
55cbb6e
Merge remote-tracking branch 'origin/master' into yahya/6870-fix-memo…
thep2p Nov 9, 2023
3d1bded
Update cadence to v0.42.5
SupunS Nov 10, 2023
c5032d8
use random string
kc1116 Nov 10, 2023
2bfd780
update godoc
kc1116 Nov 10, 2023
0cda3cd
Merge branch 'master' into ramtin/evm-integrate-into-fvm
devbugging Nov 10, 2023
72e9efd
Merge pull request #4906 from onflow/misha/6894-buildjet-ci-test
gomisha Nov 10, 2023
b657d93
add in memory register store
zhangchiqing Oct 18, 2023
a979a3a
update comments
zhangchiqing Oct 18, 2023
b456944
add comment and update GetUpdatedRegister
zhangchiqing Oct 20, 2023
4196b01
refactor IsErrPruned
zhangchiqing Nov 1, 2023
0fc6db9
update tests
zhangchiqing Nov 1, 2023
4967fdd
prefix with tests InMemoryRegister
zhangchiqing Nov 1, 2023
2ee3128
use t.Run
zhangchiqing Nov 1, 2023
dc118a0
Apply suggestions from code review
zhangchiqing Nov 1, 2023
3e6d6ac
Apply suggestions from code review
zhangchiqing Nov 1, 2023
bbfdd07
address review comments
zhangchiqing Nov 2, 2023
434dc0e
Apply suggestions from code review
zhangchiqing Nov 6, 2023
6c7c6d1
fix linter
zhangchiqing Nov 6, 2023
99bae7c
fix linter
zhangchiqing Nov 6, 2023
8d4207b
fix lint
zhangchiqing Nov 10, 2023
2baa78d
Merge branch 'master' into supun/update-cadence-v0.42.5
turbolent Nov 10, 2023
c472af0
use RegisterEntries
zhangchiqing Nov 10, 2023
e4011e4
Merge pull request #4990 from onflow/supun/update-cadence-v0.42.5
turbolent Nov 10, 2023
400e6a9
add chainhash to integration
Nov 10, 2023
7c0c5b3
add chainhash to insecure
Nov 10, 2023
9b64708
add chainhash to integration
Nov 10, 2023
f253b09
adds duration to the startup log
thep2p Nov 10, 2023
87b7c0a
update mocks
zhangchiqing Nov 10, 2023
23c304d
Merge pull request #4836 from onflow/leo/storehouse-in-memory-regsite…
zhangchiqing Nov 10, 2023
3a86983
adds TestNewSubscriptionRecordCache
thep2p Nov 10, 2023
18a0039
Merge pull request #5006 from onflow/gregor/evm/import-fix
ramtinms Nov 10, 2023
38140d8
adds TestGetSubscribedTopics
thep2p Nov 10, 2023
67ea040
Merge branch 'master' into ramtin/evm-integrate-into-fvm
ramtinms Nov 10, 2023
398c031
adds TestDuplicateTopics
thep2p Nov 10, 2023
6006f62
Merge branch 'master' into ramtin/evm-integrate-into-fvm
ramtinms Nov 10, 2023
3c41a1a
adds test move update cycle
thep2p Nov 10, 2023
0649517
Merge branch 'master' into yahya/6895-removing-unicast-manager
thep2p Nov 10, 2023
6b60162
adds TestSubscriptionValidator_Integration
thep2p Nov 10, 2023
863c937
adds TestMoveUpdateCycleWithDifferentPeers
thep2p Nov 10, 2023
c9ad745
update emulator version
ramtinms Nov 10, 2023
1a6d388
updates mocks
thep2p Nov 10, 2023
230d20f
fixes build errors in insecure package
thep2p Nov 10, 2023
864f009
Merge branch 'master' into yahya/6870-fix-memory-intensive-issues-part-1
thep2p Nov 10, 2023
b310a64
adds TestSubscriptionProvider_GetSubscribedTopics_SkippingUnknownPeers
thep2p Nov 10, 2023
3b479f6
minor fixes
ramtinms Nov 11, 2023
1be2eeb
add comment explainin idProvider mock expectations
kc1116 Nov 13, 2023
374a9b9
use unittest random string
kc1116 Nov 13, 2023
f3b6fd1
add comment about continue statement
kc1116 Nov 13, 2023
bb5f960
Update fixtures.go
kc1116 Nov 13, 2023
a4307b2
Merge branch 'master' into khalil/6460-sybil-attack
kc1116 Nov 13, 2023
c66b3d6
Merge branch 'master' into khalil/update-inspector-logging
kc1116 Nov 13, 2023
80735b6
Merge pull request #4968 from onflow/khalil/update-inspector-logging
kc1116 Nov 13, 2023
5f9076d
Merge branch 'master' of github.com:onflow/flow-go into khalil/6460-s…
kc1116 Nov 13, 2023
dfc5d04
Merge branch 'khalil/6460-sybil-attack' of github.com:onflow/flow-go …
kc1116 Nov 13, 2023
9c88e31
Merge pull request #4773 from onflow/khalil/6460-sybil-attack
kc1116 Nov 13, 2023
65d730e
Merge branch 'master' into yahya/6895-removing-unicast-manager
thep2p Nov 14, 2023
6ce5186
Merge branch 'master' into yahya/improve-libp2p-logging
thep2p Nov 14, 2023
a4fd095
Merge branch 'master' into ramtin/evm-integrate-into-fvm
ramtinms Nov 14, 2023
0fca12d
Merge branch 'master' into yahya/6870-fix-memory-intensive-issues-part-1
thep2p Nov 14, 2023
23f2cf3
Merge pull request #4977 from onflow/leo/storehouse-finalized-reader
zhangchiqing Nov 14, 2023
5d07b31
Merge pull request #4866 from onflow/ramtin/evm-integrate-into-fvm
ramtinms Nov 14, 2023
817c237
Merge branch 'master' into bastian/evm-deposit
ramtinms Nov 14, 2023
bef32cd
small fixes
ramtinms Nov 14, 2023
4c73a92
fixes merge conflicts
thep2p Nov 14, 2023
6f374a1
remove unnecessary variable declaration
turbolent Nov 14, 2023
fbc75b8
add support for testnet chain
turbolent Nov 14, 2023
4e43d7e
generalize support for all chains
turbolent Nov 14, 2023
4eeb13c
Merge branch 'master' into yahya/improve-libp2p-logging
thep2p Nov 14, 2023
4a473be
lint fix
thep2p Nov 14, 2023
beec792
restoore gating EVM setup behind feature flag
turbolent Nov 14, 2023
0e003ca
lint fix
thep2p Nov 14, 2023
e13a94f
Merge branch 'master' into yahya/6870-fix-memory-intensive-issues-part-1
thep2p Nov 14, 2023
443bf8a
consolidates PeerIdFixtureB with PeerIdFixture
thep2p Nov 14, 2023
08bf30e
adds lint and tidy to insecure package
thep2p Nov 14, 2023
fa7a065
Merge pull request #4898 from onflow/yahya/improve-libp2p-logging
thep2p Nov 14, 2023
9b1a4cc
lint fix
thep2p Nov 14, 2023
cc27bad
Revert "lint fix"
thep2p Nov 14, 2023
99bc1fd
lint fix
thep2p Nov 14, 2023
75fa942
Merge pull request #4889 from onflow/bastian/evm-deposit
turbolent Nov 14, 2023
f7d1eef
Merge branch 'master' into yahya/6870-fix-memory-intensive-issues-part-1
thep2p Nov 14, 2023
22a551c
Merge branch 'bastian/evm-deposit' into bastian/evm-withdraw
turbolent Nov 14, 2023
554d49a
Merge branch 'master' into bastian/evm-withdraw
turbolent Nov 14, 2023
863357b
revert the account not found error on withdraw
ramtinms Nov 14, 2023
ffd4745
define direct call types
ramtinms Oct 24, 2023
9dbd415
update docs
ramtinms Oct 24, 2023
2cee790
remove unnecessary event types
ramtinms Oct 24, 2023
6e6a1ba
.
ramtinms Oct 24, 2023
b05bb9c
Merge pull request #4890 from onflow/bastian/evm-withdraw
turbolent Nov 14, 2023
cd0337a
add more contract types for testing
ramtinms Oct 25, 2023
720d32f
fix tests
ramtinms Nov 14, 2023
740ce99
Merge branch 'bastian/evm-withdraw' into bastian/evm-deploy
turbolent Nov 14, 2023
75ca3e3
Merge branch 'bastian/evm-deploy' into bastian/evm-fix-tests
turbolent Nov 14, 2023
7876b16
Merge branch 'ramtin/evm-add-dummy-kitty-contract' of github.com:onfl…
ramtinms Nov 14, 2023
412c409
Merge branch 'bastian/evm-fix-tests' into bastian/evm-improve-tests
turbolent Nov 14, 2023
333c47c
Merge branch 'master' into bastian/evm-deploy
turbolent Nov 15, 2023
972fe11
skip test, requires funding (implemented in follow up PR)
turbolent Nov 15, 2023
793d9b6
Merge branch 'bastian/evm-deploy' into bastian/evm-fix-tests
turbolent Nov 15, 2023
fde902e
Merge branch 'bastian/evm-fix-tests' into bastian/evm-improve-tests
turbolent Nov 15, 2023
c5030cf
unskip test
turbolent Nov 15, 2023
ac2fa03
Merge pull request #4897 from onflow/bastian/evm-deploy
turbolent Nov 15, 2023
18f84a0
Merge branch 'master' into bastian/evm-fix-tests
turbolent Nov 15, 2023
7682f9c
check error
turbolent Nov 15, 2023
43684b9
Merge pull request #4941 from onflow/bastian/evm-fix-tests
turbolent Nov 15, 2023
2a61251
Merge branch 'master' into bastian/evm-improve-tests
turbolent Nov 15, 2023
ccb723f
Merge pull request #4986 from onflow/bastian/evm-improve-tests
turbolent Nov 15, 2023
73afa68
• extended compile-time checks for telemetry consumer enforcing that …
Nov 15, 2023
68cf90e
reduced notifications consumer interface in PaceMaker, as it only emi…
Nov 15, 2023
cf7212d
Merge branch 'master' into ramtin/evm-add-dummy-kitty-contract
turbolent Nov 15, 2023
3eab0d8
update tests
ramtinms Nov 15, 2023
cb50e71
Merge branch 'master' into alex/partially_missing_consensus_telemetry
Nov 15, 2023
3b01d42
Merge branch 'master' into janez/ms-per-computation-metrics
janezpodhostnik Nov 15, 2023
e855f73
Refactor event emmision code
janezpodhostnik Nov 9, 2023
aad2f84
Merge pull request #5020 from onflow/alex/partially_missing_consensus…
Nov 15, 2023
c1ec969
Merge pull request #4872 from onflow/ramtin/evm-add-dummy-kitty-contract
ramtinms Nov 15, 2023
d5aa848
Merge branch 'master' into yahya/fix-metrics-nil-derefrencing
thep2p Nov 15, 2023
f34bc32
Merge remote-tracking branch 'origin/master' into yahya/6870-fix-memo…
thep2p Nov 15, 2023
d3ec55d
Update network/p2p/unicast/README.MD
thep2p Nov 15, 2023
1a82273
Merge branch 'master' into ramtin/evm-add-handler-benchmark
ramtinms Nov 16, 2023
b29eece
expose more test utility
ramtinms Nov 16, 2023
257d274
lint
ramtinms Nov 16, 2023
fa477d9
Merge pull request #4615 from onflow/janez/ms-per-computation-metrics
janezpodhostnik Nov 16, 2023
856d840
add register store
zhangchiqing Nov 6, 2023
4d7a9bf
update LastFinalizedAndExecutedHeight
zhangchiqing Nov 6, 2023
2c3d44d
convert storage.ErrNotFound to nil
zhangchiqing Nov 10, 2023
f7d8ede
fix lint
zhangchiqing Nov 10, 2023
ab5b93f
Merge pull request #4940 from onflow/leo/register-store
zhangchiqing Nov 16, 2023
8df9506
Merge branch 'master' into gregor/bugfix/bench-test-state-fixture
devbugging Nov 16, 2023
005ac82
Merge branch 'master' into janez/change-event-emission-code
j1010001 Nov 16, 2023
1131f17
Merge remote-tracking branch 'origin/master' into yahya/6895-removing…
thep2p Nov 16, 2023
3263ab6
fixes the logger
thep2p Nov 16, 2023
1399151
Merge pull request #4833 from onflow/gregor/bugfix/bench-test-state-f…
devbugging Nov 16, 2023
4973803
Merge branch 'master' into yahya/6895-removing-unicast-manager
thep2p Nov 16, 2023
48f255f
moving ready to the select-case
thep2p Nov 16, 2023
e3525d3
moving ready to select-case
thep2p Nov 16, 2023
d6e0d92
Merge pull request #4951 from onflow/yahya/6895-removing-unicast-manager
thep2p Nov 16, 2023
a46c466
revises the error by update loop to make it irrecoverable
thep2p Nov 16, 2023
962adef
clean up benchmarking
ramtinms Nov 16, 2023
c392599
Merge branch 'master' into ramtin/evm-add-handler-benchmark
ramtinms Nov 16, 2023
d83fab5
adds select case for startup of subscription provider
thep2p Nov 16, 2023
c0d7e07
Update network/p2p/scoring/subscription_provider.go
thep2p Nov 16, 2023
1a841f1
Merge branch 'master' into yahya/fix-metrics-nil-derefrencing
thep2p Nov 16, 2023
ddfcc9f
adds documentation to subscription record cache
thep2p Nov 16, 2023
a433ec1
Merge branch 'yahya/6870-fix-memory-intensive-issues-part-1' of githu…
thep2p Nov 16, 2023
ba7b727
Merge branch 'master' into yahya/6870-fix-memory-intensive-issues-part-1
thep2p Nov 16, 2023
b802e46
Merge branch 'master' into ramtin/evm-add-handler-benchmark
ramtinms Nov 16, 2023
db47e4d
fixes a bug with subscription record id
thep2p Nov 16, 2023
4853b4c
Merge branch 'yahya/6870-fix-memory-intensive-issues-part-1' of githu…
thep2p Nov 16, 2023
f8daccd
adds more documentation for current cycle
thep2p Nov 16, 2023
4223549
Merge pull request #4988 from onflow/yahya/6870-fix-memory-intensive-…
thep2p Nov 16, 2023
45d22ee
Merge branch 'master' into yahya/fix-metrics-nil-derefrencing
thep2p Nov 16, 2023
1628d29
Merge pull request #4972 from onflow/yahya/fix-metrics-nil-derefrencing
thep2p Nov 17, 2023
c82af09
Merge branch 'master' into janez/change-event-emission-code
janezpodhostnik Nov 17, 2023
66cb9b6
Merge pull request #4982 from onflow/janez/change-event-emission-code
janezpodhostnik Nov 17, 2023
8b1cb0b
fix epoch event docs
jordanschalm Nov 17, 2023
8fd73e4
Merge branch 'master' into ramtin/evm-add-handler-benchmark
ramtinms Nov 17, 2023
48b2212
[Access] Handle script canceled and timeout errors
peterargue Nov 17, 2023
059c392
Merge pull request #5035 from onflow/jordan/hf-fix-epoch-event-docs
jordanschalm Nov 17, 2023
9b0633e
Merge pull request #4879 from onflow/ramtin/evm-add-handler-benchmark
ramtinms Nov 17, 2023
4c7d1b1
[Access] Make script exec configurable
peterargue Nov 17, 2023
4941a36
Make computation limit configurable on ENs
peterargue Nov 17, 2023
7717188
set limit setting once
peterargue Nov 17, 2023
bb6f2b8
undo whitespace changes
peterargue Nov 17, 2023
dd3e760
add storehouse loader
zhangchiqing Nov 15, 2023
03fd33c
add loaders
zhangchiqing Nov 16, 2023
17d0b61
add comments update log
zhangchiqing Nov 17, 2023
ab72def
add comments
zhangchiqing Nov 17, 2023
4685e19
update loader
zhangchiqing Nov 17, 2023
fec85ee
Merge pull request #5028 from onflow/leo/storehouse-loader
zhangchiqing Nov 17, 2023
fb44a86
add extending block snapshot
zhangchiqing Nov 10, 2023
3e1a677
fix tests
zhangchiqing Nov 10, 2023
edfce9e
fix lint
zhangchiqing Nov 14, 2023
bfe8630
update interface
zhangchiqing Nov 16, 2023
ad80732
update tests
zhangchiqing Nov 16, 2023
904bed0
fix lint
zhangchiqing Nov 18, 2023
538e72e
Merge pull request #5008 from onflow/leo/storehouse-extending-block-s…
zhangchiqing Nov 18, 2023
ceea289
update committer
zhangchiqing Nov 16, 2023
33ee241
update mocks
zhangchiqing Nov 16, 2023
4aac6bc
update committer tests
zhangchiqing Nov 16, 2023
f1e4b27
refactor collector
zhangchiqing Nov 16, 2023
98de85a
update mocks
zhangchiqing Nov 16, 2023
1fc0373
update bootstrap
zhangchiqing Nov 16, 2023
86d37c8
fix noop committer
zhangchiqing Nov 16, 2023
e245de1
fix computer_test
zhangchiqing Nov 16, 2023
56ac33b
fix tests
zhangchiqing Nov 16, 2023
72c9499
refactor test
zhangchiqing Nov 17, 2023
6e9e5df
update committer tests
zhangchiqing Nov 18, 2023
576092a
fix tests
zhangchiqing Nov 18, 2023
867579e
Merge branch 'feature/flip-204-epoch-target-end-time' of github.com:o…
jordanschalm Nov 20, 2023
b28e867
Update engine/access/rpc/backend/backend_scripts_test.go
peterargue Nov 20, 2023
6948717
Merge pull request #5036 from onflow/petera/5030-handle-script-cancel…
peterargue Nov 20, 2023
2608c0f
Merge pull request #5037 from onflow/petera/4776-make-script-exec-con…
peterargue Nov 20, 2023
b591ddb
fix committer tests
zhangchiqing Nov 20, 2023
67fdf93
add comment
zhangchiqing Nov 20, 2023
086b714
update tests
zhangchiqing Nov 21, 2023
bb7f469
Added implementation for execution api engine
AndriiDiachuk Nov 21, 2023
df36c68
Added tests for execution api engine
AndriiDiachuk Nov 21, 2023
f280b01
Fixed issues based on comments
AndriiDiachuk Nov 21, 2023
9b77ac8
Added accidentally removed code
AndriiDiachuk Nov 21, 2023
bb53e5f
Updated implementations following protobuf changes,updated mocks
AndriiDiachuk Nov 21, 2023
3071d24
Linted
AndriiDiachuk Nov 21, 2023
a974d48
[Access] Update websockets event streaming to return JSON-CDC encoded…
peterargue Nov 22, 2023
bce44e6
Added tests for sentinel errors
AndriiDiachuk Nov 22, 2023
5e07a8b
Update engine/execution/rpc/engine.go
AndriiDiachuk Nov 22, 2023
583f9f8
Merge pull request #5042 from AndriiDiachuk/AndriiDiachuk/4754-add-en…
durkmurder Nov 22, 2023
0ba81ff
Merge pull request #5029 from onflow/leo/storehouse-committer
zhangchiqing Nov 22, 2023
ff4f998
update NewStorageSnapshot
zhangchiqing Nov 17, 2023
79f89bc
update mocks
zhangchiqing Nov 17, 2023
b62a57b
update tests
zhangchiqing Nov 17, 2023
149679c
refactor script engine
zhangchiqing Nov 17, 2023
d86dbb9
update mocks
zhangchiqing Nov 17, 2023
274a9e0
fix tests
zhangchiqing Nov 17, 2023
5544e28
fix tests
zhangchiqing Nov 17, 2023
eb784f5
remove scripts engine tests
zhangchiqing Nov 17, 2023
6197f40
update errors
zhangchiqing Nov 17, 2023
94464f4
update tests
zhangchiqing Nov 17, 2023
eb60fe3
refactor tests
zhangchiqing Nov 17, 2023
a5d8fcc
test CreateSnapshot
zhangchiqing Nov 17, 2023
357a0c9
Merge pull request #5031 from onflow/leo/storehouse-execution-state
zhangchiqing Nov 22, 2023
6c2907f
add executing block snapshot
zhangchiqing Nov 8, 2023
1550ba3
reuse convert functions
zhangchiqing Nov 8, 2023
05bdd87
add block_end_snapshot tests
zhangchiqing Nov 9, 2023
e85ed70
remove changes
zhangchiqing Nov 16, 2023
9182729
Apply suggestions from code review
zhangchiqing Nov 16, 2023
5e22f68
add todo
zhangchiqing Nov 16, 2023
4bdab71
Update engine/execution/storehouse/block_end_snapshot_test.go
zhangchiqing Nov 16, 2023
c6f93b1
Update engine/execution/storehouse/block_end_snapshot_test.go
zhangchiqing Nov 16, 2023
8d49e08
fix lint
zhangchiqing Nov 16, 2023
d6c45f6
update comment
zhangchiqing Nov 20, 2023
6a57758
add back interface
zhangchiqing Nov 20, 2023
1894f9e
update getFromStorage
zhangchiqing Nov 21, 2023
c212feb
handle not found case
zhangchiqing Nov 22, 2023
4494a66
Merge pull request #4985 from onflow/leo/storehouse-blockend-snapshot
zhangchiqing Nov 22, 2023
c57100b
add IsBlockExcuted
zhangchiqing Nov 17, 2023
29df35e
update state commmitment by block id
zhangchiqing Nov 17, 2023
abe8680
update mocks
zhangchiqing Nov 22, 2023
9bc5f33
fix lint
zhangchiqing Nov 22, 2023
0859e5c
update unexecuted_loader
zhangchiqing Nov 22, 2023
2d2d432
fix ingestion tests
zhangchiqing Nov 22, 2023
392f746
fix stop control
zhangchiqing Nov 22, 2023
d6f1570
use IsParentExecuted
zhangchiqing Nov 22, 2023
c41dc15
fix loader tests
zhangchiqing Nov 22, 2023
026d204
Merge pull request #4116 from onflow/move-stale-issue-workflow
Kay-Zee Nov 22, 2023
5eb72b7
Fix bug in reencoding and update tests
peterargue Nov 22, 2023
a368dde
Merge branch 'master' into petera/5047-fix-wsrest-events-encoding
peterargue Nov 22, 2023
cdcf18e
Merge pull request #4622 from onflow/jribbink-patch-1
Kay-Zee Nov 22, 2023
3a9f871
Merge pull request #5044 from onflow/leo/storehouse-execution-state-2
zhangchiqing Nov 22, 2023
642635d
Merge pull request #5048 from onflow/petera/5047-fix-wsrest-events-en…
peterargue Nov 23, 2023
2afeb00
Merge branch 'feature/flip-204-epoch-target-end-time' of github.com:o…
jordanschalm Nov 24, 2023
0623b55
Merge branch 'master' into jordan/sync-feat-flip204-master
jordanschalm Nov 24, 2023
677abf8
update core-contracts version and state commitment constants
jordanschalm Nov 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix ingestion tests
  • Loading branch information
zhangchiqing committed Nov 22, 2023
commit 2d2d43282c55259074e8f8b3e67337bdcb8912a7
109 changes: 60 additions & 49 deletions engine/execution/ingestion/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/fvm/storage/snapshot"

enginePkg "github.com/onflow/flow-go/engine"
"github.com/onflow/flow-go/engine/execution"
Expand Down Expand Up @@ -171,6 +172,7 @@ func TestExecuteOneBlock(t *testing.T) {
blockA := makeBlockWithCollection(store.RootBlock, &col)
result := store.CreateBlockAndMockResult(t, blockA)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -226,6 +228,7 @@ func TestExecuteBlocks(t *testing.T) {
store.CreateBlockAndMockResult(t, blockA)
store.CreateBlockAndMockResult(t, blockB)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -275,6 +278,7 @@ func TestExecuteNextBlockIfCollectionIsReady(t *testing.T) {
// C2 is available in storage
require.NoError(t, ctx.collections.Store(&col2))

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -319,6 +323,7 @@ func TestExecuteBlockOnlyOnce(t *testing.T) {
blockA := makeBlockWithCollection(store.RootBlock, &col)
store.CreateBlockAndMockResult(t, blockA)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -375,6 +380,7 @@ func TestExecuteForkConcurrently(t *testing.T) {
store.CreateBlockAndMockResult(t, blockA)
store.CreateBlockAndMockResult(t, blockB)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -425,6 +431,7 @@ func TestExecuteBlockInOrder(t *testing.T) {
store.CreateBlockAndMockResult(t, blockB)
store.CreateBlockAndMockResult(t, blockC)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -495,6 +502,7 @@ func TestStopAtHeightWhenFinalizedBeforeExecuted(t *testing.T) {
})
require.NoError(t, err)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -562,6 +570,7 @@ func TestStopAtHeightWhenExecutedBeforeFinalized(t *testing.T) {
})
require.NoError(t, err)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -623,6 +632,7 @@ func TestStopAtHeightWhenExecutionFinalization(t *testing.T) {
})
require.NoError(t, err)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -678,6 +688,7 @@ func TestExecutedBlockUploadedFailureDoesntBlock(t *testing.T) {
blockA := makeBlockWithCollection(store.RootBlock, &col)
result := store.CreateBlockAndMockResult(t, blockA)

ctx.mockIsBlockExecuted(store)
ctx.mockStateCommitmentByBlockID(store)
ctx.mockGetExecutionResultID(store)
ctx.executionState.On("NewStorageSnapshot", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down Expand Up @@ -741,63 +752,63 @@ func makeBlockWithCollection(parent *flow.Header, cols ...*flow.Collection) *ent
return executableBlock
}

func (ctx *testingContext) mockIsBlockExecuted(store *mocks.MockBlockStore) {
ctx.executionState.On("IsBlockExecuted", mock.Anything, mock.Anything).
Return(func(height uint64, blockID flow.Identifier) (bool, error) {
_, err := store.GetExecuted(blockID)
if err != nil {
return false, nil
}
return true, nil
})
}

func (ctx *testingContext) mockStateCommitmentByBlockID(store *mocks.MockBlockStore) {
mocked := ctx.executionState.On("StateCommitmentByBlockID", mock.Anything)
// https://github.com/stretchr/testify/issues/350#issuecomment-570478958
mocked.RunFn = func(args mock.Arguments) {
blockID := args[1].(flow.Identifier)
result, err := store.GetExecuted(blockID)
if err != nil {
mocked.ReturnArguments = mock.Arguments{flow.StateCommitment{}, storageerr.ErrNotFound}
return
}
mocked.ReturnArguments = mock.Arguments{result.Result.CurrentEndState(), nil}
}
ctx.executionState.On("StateCommitmentByBlockID", mock.Anything).
Return(func(blockID flow.Identifier) (flow.StateCommitment, error) {
result, err := store.GetExecuted(blockID)
if err != nil {
return flow.StateCommitment{}, storageerr.ErrNotFound
}
return result.Result.CurrentEndState(), nil
})
}

func (ctx *testingContext) mockGetExecutionResultID(store *mocks.MockBlockStore) {

mocked := ctx.executionState.On("GetExecutionResultID", mock.Anything, mock.Anything)
mocked.RunFn = func(args mock.Arguments) {
blockID := args[1].(flow.Identifier)
blockResult, err := store.GetExecuted(blockID)
if err != nil {
mocked.ReturnArguments = mock.Arguments{nil, storageerr.ErrNotFound}
return
}

mocked.ReturnArguments = mock.Arguments{
blockResult.Result.ExecutionReceipt.ExecutionResult.ID(), nil}
}
ctx.executionState.On("GetExecutionResultID", mock.Anything, mock.Anything).
Return(func(ctx context.Context, blockID flow.Identifier) (flow.Identifier, error) {
blockResult, err := store.GetExecuted(blockID)
if err != nil {
return flow.ZeroID, storageerr.ErrNotFound
}

return blockResult.Result.ExecutionReceipt.ExecutionResult.ID(), nil
})
}

func (ctx *testingContext) mockComputeBlock(store *mocks.MockBlockStore) {
mocked := ctx.computationManager.On("ComputeBlock", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
mocked.RunFn = func(args mock.Arguments) {
block := args[2].(*entity.ExecutableBlock)
blockResult, ok := store.ResultByBlock[block.ID()]
if !ok {
mocked.ReturnArguments = mock.Arguments{nil, fmt.Errorf("block %s not found", block.ID())}
return
}
mocked.ReturnArguments = mock.Arguments{blockResult.Result, nil}
}
ctx.computationManager.On("ComputeBlock", mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(func(ctx context.Context,
parentBlockExecutionResultID flow.Identifier,
block *entity.ExecutableBlock,
snapshot snapshot.StorageSnapshot) (
*execution.ComputationResult, error) {
blockResult, ok := store.ResultByBlock[block.ID()]
if !ok {
return nil, fmt.Errorf("block %s not found", block.ID())
}
return blockResult.Result, nil
})
}

func (ctx *testingContext) mockSaveExecutionResults(store *mocks.MockBlockStore, wg *sync.WaitGroup) {
mocked := ctx.executionState.
On("SaveExecutionResults", mock.Anything, mock.Anything)

mocked.RunFn = func(args mock.Arguments) {
result := args[1].(*execution.ComputationResult)

err := store.MarkExecuted(result)
if err != nil {
mocked.ReturnArguments = mock.Arguments{err}
wg.Done()
return
}
mocked.ReturnArguments = mock.Arguments{nil}
wg.Done()
}
ctx.executionState.On("SaveExecutionResults", mock.Anything, mock.Anything).
Return(func(ctx context.Context, result *execution.ComputationResult) error {
defer wg.Done()
err := store.MarkExecuted(result)
if err != nil {
return err
}
return nil
})
}