Skip to content

bug: setBalance not working as expected #32

@pyk

Description

@pyk

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

1.33.0

Current Behavior

When I try to set DAI, USDC and USDT balance on Mainnet fork via gui.setBalance the balance is set to zero:

Balance of 0x7a81c7A8eaC3655b69Fb22055d40217D9D8a5281 is now 0
Balance of 0x7a81c7A8eaC3655b69Fb22055d40217D9D8a5281 is now 0
Balance of 0x7a81c7A8eaC3655b69Fb22055d40217D9D8a5281 is now 0

Expected Behavior

The DAI, USDC and USDT balance of a test account should be updated

Steps To Reproduce

Set GUARDIAN_UI_ALCHEMY_API_KEY

Then use the following test example:

import { test } from '@guardianui/test'

test('Wrap Token to saToken', async ({ page, gui }) => {
  // Fork Mainnet
  await gui.initializeChain(1, 17585757)

  // Mock balances
  await gui.setEthBalance('100000000000000000000000')
  await gui.setBalance(
    '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
    '1000000000000'
  )
  await gui.setBalance(
    '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT
    '1000000000000'
  )
  await gui.setBalance(
    '0x6b175474e89094c44da98b954eedeac495271d0f', // DAI
    '1000000000000000000000000'
  )
})

The console log should output the following:

Balance of 0x7a81c7A8eaC3655b69Fb22055d40217D9D8a5281 is now 0
Balance of 0x7a81c7A8eaC3655b69Fb22055d40217D9D8a5281 is now 0
Balance of 0x7a81c7A8eaC3655b69Fb22055d40217D9D8a5281 is now 0

Link to Minimal Reproducible Example

No response

Operating system

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy

Browser

Chrome

Anything else?

Currently I need to specify the slot storage manually in order to set the token balance

For example:

  await setBalanceAtSlot({
    token: '0xae78736cd615f374d3085123a210448e74fc6393', // rETH
    slotNumber: '1',
    value: '10000000000000000000000',
    gui,
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions