-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into kai/SDK-1719-max-age
- Loading branch information
Showing
90 changed files
with
12,967 additions
and
10,580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { ActorMethod, Actor, HttpAgent } from '@dfinity/agent'; | ||
import util from 'util'; | ||
import exec from 'child_process'; | ||
const execAsync = util.promisify(exec.exec); | ||
|
||
// eslint-disable-next-line prefer-const | ||
let stdout; | ||
try { | ||
({ stdout } = await execAsync('dfx canister id trap')); | ||
} catch { | ||
await execAsync('dfx deploy trap'); | ||
({ stdout } = await execAsync('dfx canister id trap')); | ||
} | ||
|
||
export const idlFactory = ({ IDL }) => { | ||
return IDL.Service({ | ||
Throw: IDL.Func([], [], []), | ||
test: IDL.Func([], [], []), | ||
}); | ||
}; | ||
|
||
export interface _SERVICE { | ||
Throw: ActorMethod<[], undefined>; | ||
test: ActorMethod<[], undefined>; | ||
} | ||
|
||
describe('trap', () => { | ||
it('should trap', async () => { | ||
const canisterId = stdout.trim(); | ||
const agent = await HttpAgent.create({ | ||
host: 'http://localhost:4943', | ||
shouldFetchRootKey: true, | ||
}); | ||
const actor = Actor.createActor<_SERVICE>(idlFactory, { canisterId, agent }); | ||
try { | ||
await actor.Throw(); | ||
} catch (error) { | ||
console.log(error); | ||
expect(error.reject_message).toBe('foo'); | ||
} | ||
}); | ||
it('should trap', async () => { | ||
const canisterId = stdout.trim(); | ||
const agent = await HttpAgent.create({ | ||
host: 'http://localhost:4943', | ||
shouldFetchRootKey: true, | ||
}); | ||
const actor = Actor.createActor<_SERVICE>(idlFactory, { canisterId, agent }); | ||
try { | ||
await actor.test(); | ||
} catch (error) { | ||
expect(error.reject_message).toContain('Canister called `ic0.trap` with message: trapping'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.