Skip to content

Commit

Permalink
test: integrate publicProvider into SmartContract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Dec 30, 2024
1 parent 4cb3d4f commit df8aece
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/integration/smartContract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
MIN_GAS_CALL,
SmartContract,
} from '../../src/smartContracts'
import { provider } from './setup'
import { provider, publicProvider } from './setup'
import { Address, Args, bytesToStr, Mas } from '../../src/basicElements'

import { execute } from '../../src/basicElements/bytecode'
Expand All @@ -27,7 +27,7 @@ describe('Smart Contract', () => {
}

const opId = await execute(
provider.client,
publicProvider.client,
provider.account.privateKey,
byteCode,
opts
Expand Down Expand Up @@ -55,6 +55,7 @@ describe('Smart Contract', () => {

describe('SmartContract - Call ', () => {
let contractTest: SmartContract
let contractPublicProviderTest: SmartContract

beforeAll(async () => {
const byteCode = fs.readFileSync(contractPath)
Expand All @@ -73,6 +74,11 @@ describe('Smart Contract', () => {
deployOptions
)

contractPublicProviderTest = new SmartContract(
publicProvider,
contractTest.address
)

expect(Address.fromString(contractTest.address).isEOA).toBeFalsy()
})

Expand All @@ -83,6 +89,12 @@ describe('Smart Contract', () => {
expect(firstEvent).toBe("I'm an event!")
})

test('call fail with public provider', async () => {
expect(contractPublicProviderTest.call('event')).rejects.toThrow(
'Provider does not support callSC'
)
})

test('call that set a value in the datastore', async () => {
const key = 'myKey'
const value = 'myValue'
Expand Down

0 comments on commit df8aece

Please sign in to comment.