Skip to content

Commit 17ee57f

Browse files
[NONEVM-2276] TS tests Timelock Execute (#100)
1 parent 525739d commit 17ee57f

File tree

4 files changed

+651
-14
lines changed

4 files changed

+651
-14
lines changed

contracts/tests/mcms/BaseTest.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface TestContracts {
4444

4545
export class BaseTestSetup {
4646
static readonly MIN_DELAY = 24n * 60n * 60n * 7n
47-
static readonly DONE_TIMESTAMP = 1
47+
static readonly DONE_TIMESTAMP = 1n
4848
static readonly NO_PREDECESSOR = 0n
4949
static readonly EMPTY_SALT = 0n
5050

@@ -190,9 +190,9 @@ export class BaseTestSetup {
190190
/**
191191
* Setup the call proxy contract
192192
*/
193-
async setupCallProxyContract(): Promise<void> {
193+
async setupCallProxyContract(testId: string): Promise<void> {
194194
const data = {
195-
id: crc32('mcms.call-proxy.test-integration'),
195+
id: crc32(`mcms.call-proxy.${testId}`),
196196
target: this.bind.timelock.address,
197197
}
198198
this.bind.callProxy = this.blockchain.openContract(
@@ -203,9 +203,9 @@ export class BaseTestSetup {
203203
/**
204204
* Setup the counter contract
205205
*/
206-
async setupCounterContract(): Promise<void> {
206+
async setupCounterContract(testId: string): Promise<void> {
207207
const data = {
208-
id: crc32('mcms.counter.test-integration'),
208+
id: crc32(`mcms.counter.${testId}`),
209209
value: 0,
210210
ownable: {
211211
owner: this.bind.timelock.address,
@@ -239,15 +239,29 @@ export class BaseTestSetup {
239239
expect(await this.bind.ac.getRoleAdmin(rbactl.roles.admin)).toEqual(rbactl.roles.admin)
240240
}
241241

242+
// TODO
243+
// deployCallProxyContract() {
244+
// const body = callproxy.builder.message.topUp.encode({ queryId: 1n })
245+
// return this.bind.callProxy.sendInternal(this.acc.deployer.getSender(), toNano('0.05'), body)
246+
// }
247+
248+
deployCounterContract() {
249+
// const body = counter.builder.message.topUp.encode({ queryId: 1n }) // TODO use TopUp after it is implemented
250+
const body = beginCell().endCell()
251+
return this.bind.counter.sendInternal(this.acc.deployer.getSender(), toNano('0.05'), body)
252+
}
253+
242254
/**
243255
* Complete setup for all contracts - convenience method that combines all setup steps
244256
*/
245257
async setupAll(testId: string): Promise<void> {
246258
await this.initializeBlockchain()
247259
await this.setupTimelockContract(testId)
248-
await this.setupCallProxyContract()
249-
await this.setupCounterContract()
250260
await this.deployTimelockContract()
261+
await this.setupCallProxyContract(testId)
262+
// await this.deployCallProxyContract()
263+
await this.setupCounterContract(testId)
264+
await this.deployCounterContract()
251265
}
252266

253267
/**

contracts/tests/mcms/RBACTimelock.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import '@ton/test-utils'
66
import * as rbactl from '../../wrappers/mcms/RBACTimelock'
77
import * as ac from '../../wrappers/lib/access/AccessControl'
88
import { crc32 } from 'zlib'
9+
import { asSnakeData } from '../../utils'
910

1011
describe('RBACTimelock', () => {
1112
let code: Cell
@@ -371,12 +372,15 @@ describe('RBACTimelock', () => {
371372
const targetAccount = deployer.address
372373
const msgToSend = beginCell().endCell()
373374

374-
const op = {
375-
calls: rbactl.builder.data.call.encode({
375+
const calls = [
376+
{
376377
target: targetAccount,
377378
value: tonValue,
378379
data: msgToSend,
379-
}), // TODO: this should be an array of calls: vec<Call>
380+
},
381+
]
382+
const op = {
383+
calls: asSnakeData<rbactl.Call>(calls, (c) => rbactl.builder.data.call.encode(c).asBuilder()),
380384
predecessor: predecessor,
381385
salt: salt,
382386
}

0 commit comments

Comments
 (0)