Skip to content

Conversation

sasurobert
Copy link
Contributor

No description provided.

@andreibancioiu andreibancioiu requested a review from Copilot July 31, 2025 10:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetAllState method to the BlockchainContextMock
  • Updates imports to use specific mocks instead of worldmock dependencies
  • Creates comprehensive tests for doRunSmartContractCreate and doRunSmartContractCall methods

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)
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant