Skip to content

Fix type mismatch in VMResult tests - #6

Draft
0xrinegade with Copilot wants to merge 2 commits into
copilot/implement-solna-anchor-gleamfrom
copilot/fix-type-mismatch-errors
Draft

Fix type mismatch in VMResult tests#6
0xrinegade with Copilot wants to merge 2 commits into
copilot/implement-solna-anchor-gleamfrom
copilot/fix-type-mismatch-errors

Conversation

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown

Three tests failed because vm.airdrop and vm.add_program return security.VMResult (custom Ok/Error constructors) but used gleeunit's should.be_ok()/should.be_error() which expect standard Gleam Result.

Changes

  • vm_airdrop_test: Pattern match on security.Ok(_) instead of should.be_ok()
  • vm_add_program_success_test: Pattern match on security.Ok(_) instead of should.be_ok()
  • vm_add_program_invalid_elf_test: Pattern match on security.Error(_) instead of should.be_error()
// Before
let result = vm.airdrop(vm_state, 123, 1_000_000)
result |> should.be_ok()

// After
let result = vm.airdrop(vm_state, 123, 1_000_000)
case result {
  security.Ok(_) -> True
  _ -> False
} |> should.be_true()
Original prompt

Problem

CI job 59956903460 is failing with type mismatch errors in test/gleamsvm_test.gleam at lines 342, 351, and 360.

Error Details

error: Type mismatch
    ┌─ /home/runner/work/gleam-sbpf/gleam-sbpf/test/gleamsvm_test.gleam:342:3
Found type: security.VMResult(security.VMState)

The same error occurs at lines 342, 351, and 360.

Root Cause

The functions vm.airdrop and vm.add_program return security.VMResult(security.VMState), but the tests are using should.be_ok() and should.be_error() which expect a standard Result type.

Required Fix

Update the three failing test functions:

Line 338-344 (vm_airdrop_test):

pub fn vm_airdrop_test() {
  let vm_state = vm.new()
  let result = vm.airdrop(vm_state, 123, 1_000_000)
  
  case result {
    security.Ok(_) -> True
    _ -> False
  }
  |> should.be_true()
}

Line 346-353 (vm_add_program_success_test):

pub fn vm_add_program_success_test() {
  let vm_state = vm.new()
  let elf_data = [0x7F, 0x45, 0x4C, 0x46, 0x02, 0x01]
  let result = vm.add_program(vm_state, 999, elf_data)
  
  case result {
    security.Ok(_) -> True
    _ -> False
  }
  |> should.be_true()
}

Line 355-362 (vm_add_program_invalid_elf_test):

pub fn vm_add_program_invalid_elf_test() {
  let vm_state = vm.new()
  let invalid_data = [0x00, 0x01, 0x02, 0x03]
  let result = vm.add_program(vm_state, 999, invalid_data)
  
  case result {
    security.Error(_) -> True
    _ -> False
  }
  |> should.be_true()
}

Acceptance Criteria

  • All three test functions updated to use case pattern matching on security.VMResult
  • gleam test passes locally in the agent environment
  • No type mismatch errors
  • All existing tests continue to pass

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@devloai

devloai Bot commented Jan 9, 2026

Copy link
Copy Markdown

Unable to trigger custom agent "Code Reviewer"You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @Copilot! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

Co-authored-by: 0xrinegade <101195284+0xrinegade@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix type mismatch errors in gleamsvm_test Fix type mismatch in VMResult tests Jan 9, 2026
Copilot AI requested a review from 0xrinegade January 9, 2026 22:11
@0xrinegade

Copy link
Copy Markdown
Member

@copilot sup

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