Skip to content

Conversation

@sasurobert
Copy link
Contributor

No description provided.

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

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 pull request adds comprehensive unit tests for the vmhost package, specifically focusing on testing various VM hooks, host core functionality, error handling, and async operations. The PR improves test coverage by adding tests for small integer operations, big integer operations, big float operations, breakpoints handling, error wrapping, and async call mechanisms.

Key Changes:

  • Added unit tests for VM hooks operations (smallIntOps, bigIntOps, bigFloatOps)
  • Added tests for host core breakpoints functionality
  • Added comprehensive error wrapping tests
  • Updated existing test files to use proper mock interfaces
  • Generated new mock files for better test isolation

Reviewed Changes

Copilot reviewed 31 out of 46 changed files in this pull request and generated 18 comments.

Show a summary per file

:

File Description
vmhost/vmhooks/smallIntOps_test.go New tests for small integer VM hook operations
vmhost/vmhooks/bigIntOps_test.go New tests for big integer VM hook operations
vmhost/vmhooks/bigFloatOps_test.go New tests for big float VM hook operations
vmhost/hostCore/breakpoints_test.go New tests for breakpoint handling in host core
vmhost/errorWrapping_test.go New comprehensive tests for error wrapping functionality
vmhost/errorWrapping.go Minor refactoring of the Unwrap method
vmhost/asyncCall_test.go New tests for async call functionality
vmhost/asyncCallGroup_test.go New tests for async call group operations
vmhost/asyncCall.go Bug fix for proper cloning of byte slices
vmhost/asyncCallGroup.go Bug fix for proper cloning of callback data
mock/context/*.go Generated mock files for improved test isolation
Comments suppressed due to low confidence (3)

vmhost/vmhooks/bigFloatOps_test.go:158

  • There is an extra closing parenthesis that appears to be a syntax error. This line should be removed.
)

vmhost/vmhooks/smallIntOps_test.go:89

  • The test for SmallIntFinishSigned is incomplete. The TODO comment indicates that the test should verify the exact bytes for two's complement representation, but this verification is missing.
	// TODO: check the exact bytes for two's complement

vmhost/vmhooks/smallIntOps_test.go:52

  • The test case 'out of range' calls the function but doesn't verify the expected behavior. The comment suggests it should 'expect fail execution', but there's no assertion to verify this failure.
		hooks.SmallIntGetUnsignedArgument(0)

Comment on lines 81 to 82
true true

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.

This line contains 'true true' which appears to be a syntax error or incomplete replacement. It should be a proper method call or assignment.

Suggested change
true true

Copilot uses AI. Check for mistakes.
// Act as if the OutputContext has the requested OutputAccount cached
account.Balance = big.NewInt(42)
mockOutput.OutputAccountIsNew = false
true false
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.

This line contains 'true false' which appears to be a syntax error or incomplete replacement. It should be a proper method call or assignment.

Suggested change
true false
// No operation needed here; proceeding to test GetBalance

Copilot uses AI. Check for mistakes.

metering, _ := NewMeteringContext(host, config.MakeGasMapForTests(), uint64(15000))
host.MeteringContext = metering
host.On("Metering").Return metering
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.

Missing parentheses around the return value. It should be 'Return(metering)'.

Suggested change
host.On("Metering").Return metering
host.On("Metering").Return(metering)

Copilot uses AI. Check for mistakes.
Comment on lines 537 to 538
mockMetering.On("GasProvided").Return = 200
mockMetering.On("GasLeft").Return = 60
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.

Incorrect syntax for mock setup. It should be 'Return(200)' instead of 'Return = 200'.

Suggested change
mockMetering.On("GasProvided").Return = 200
mockMetering.On("GasLeft").Return = 60
mockMetering.On("GasProvided").Return(200)
mockMetering.On("GasLeft").Return(60)

Copilot uses AI. Check for mistakes.
Comment on lines 537 to 538
mockMetering.On("GasProvided").Return = 200
mockMetering.On("GasLeft").Return = 60
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.

Incorrect syntax for mock setup. It should be 'Return(60)' instead of 'Return = 60'.

Suggested change
mockMetering.On("GasProvided").Return = 200
mockMetering.On("GasLeft").Return = 60
mockMetering.On("GasProvided").Return(200)
mockMetering.On("GasLeft").Return(60)

Copilot uses AI. Check for mistakes.
Comment on lines +587 to +588
mockWasmerInstance.On("successCallback", nil)
mockWasmerInstance.On("errorCallback", nil)
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.

This should likely be 'On("HasFunction", "successCallback").Return(true)' to mock the function existence check.

Suggested change
mockWasmerInstance.On("successCallback", nil)
mockWasmerInstance.On("errorCallback", nil)
mockWasmerInstance.On("HasFunction", "successCallback").Return(true)
mockWasmerInstance.On("HasFunction", "errorCallback").Return(true)

Copilot uses AI. Check for mistakes.
mockWasmerInstance.AddMockMethod("successCallback", nil)
mockWasmerInstance.AddMockMethod("errorCallback", nil)
mockWasmerInstance.On("successCallback", nil)
mockWasmerInstance.On("errorCallback", nil)
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.

This should likely be 'On("HasFunction", "errorCallback").Return(true)' to mock the function existence check.

Suggested change
mockWasmerInstance.On("errorCallback", nil)
mockWasmerInstance.On("errorCallback", nil).Return(true)

Copilot uses AI. Check for mistakes.
@sasurobert
Copy link
Contributor Author

implemented in a new pr.

@sasurobert sasurobert closed this Aug 6, 2025
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.

2 participants