I'm currently working on increasing test coverage.#950
Open
sasurobert wants to merge 1 commit intomasterfrom
Open
I'm currently working on increasing test coverage.#950sasurobert wants to merge 1 commit intomasterfrom
sasurobert wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds test coverage for the VMHost execution methods by creating new test cases and updating mock imports to use more appropriate mocks.
- Adds a new
GetAllStatemethod to theBlockchainContextMock - Updates imports to use specific mocks instead of worldmock dependencies
- Creates comprehensive tests for
doRunSmartContractCreateanddoRunSmartContractCallmethods
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vmhost/mock/blockchainContextMock.go | Adds missing GetAllState method to complete the mock interface |
| vmhost/hostCore/host_test.go | Updates mock imports and test setup to use more appropriate mocks |
| vmhost/hostCore/execution_test.go | Adds new test file with comprehensive coverage for execution methods |
Comments suppressed due to low confidence (2)
vmhost/hostCore/execution_test.go:60
- The test only verifies the return code but doesn't validate other important aspects of contract creation like deployed address, gas consumption, or storage state changes.
vmOutput := h.(*vmHost).doRunSmartContractCreate(input)
vmhost/hostCore/execution_test.go:143
- The test only checks the return code but doesn't verify the actual function execution results, return data, or gas consumption that would indicate the smart contract call was properly executed.
vmOutput := h.(*vmHost).doRunSmartContractCall(input)
Comment on lines
+20
to
+27
| // StorageSimpleSC is a simple smart contract that stores a value. | ||
| var StorageSimpleSC = []byte(` | ||
| (module | ||
| (func (export "store") (param i32) | ||
| (set_local 0 (get_local 0)) | ||
| ) | ||
| (func (export "load") (result i32) | ||
| (i32.const 42) |
There was a problem hiding this comment.
The WASM bytecode in StorageSimpleSC appears to be incomplete or simplified. The set_local and get_local operations don't correspond to actual storage operations, which may not provide meaningful test coverage for smart contract execution.
Suggested change
| // StorageSimpleSC is a simple smart contract that stores a value. | |
| var StorageSimpleSC = []byte(` | |
| (module | |
| (func (export "store") (param i32) | |
| (set_local 0 (get_local 0)) | |
| ) | |
| (func (export "load") (result i32) | |
| (i32.const 42) | |
| // StorageSimpleSC is a simple smart contract that stores and retrieves a value in memory. | |
| var StorageSimpleSC = []byte(` | |
| (module | |
| (memory $0 1) ;; Define a memory block | |
| (export "memory" (memory $0)) ;; Export the memory for external access | |
| (func (export "store") (param i32) | |
| (i32.store (i32.const 0) (get_local 0)) ;; Store the input value at memory address 0 | |
| ) | |
| (func (export "load") (result i32) | |
| (i32.load (i32.const 0)) ;; Load the value from memory address 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.