Files
xahaud/hookstests/hookset/test-install.js
Richard Holland 642ebf34cd fix tests
2022-02-18 13:25:16 +00:00

103 lines
3.8 KiB
JavaScript

require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=>
{
const account = t.randomAccount();
const account2 = t.randomAccount();
t.fundFromGenesis(account).then(()=>
{
t.fundFromGenesis(account2).then(()=>
{
let hash = t.hookHash('checkstate.wasm')
t.api.submit(
{
Account: account.classicAddress,
TransactionType: "SetHook",
Hooks: [
{ Hook: {
CreateCode: t.wasm('checkstate.wasm'),
HookApiVersion: 0,
HookNamespace: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF",
HookOn: "0000000000000000"
}
}
],
Fee: "100000"
}, {wallet: account}).then(x=>
{
t.assertTxnSuccess(x)
console.log(x)
t.api.submit(
{
Account: account2.classicAddress,
TransactionType: "SetHook",
Fee: "100000",
Hooks: [
{ Hook: {
HookHash: hash
}},
{ Hook: {
}},
{ Hook: {
HookHash: hash
}}
]
}, {wallet: account2}).then(x=>
{
t.assertTxnSuccess(x)
console.log(x);
t.api.submit(
{
Account: account2.classicAddress,
TransactionType: "SetHook",
Fee: "100000",
Flags: 0,
Hooks: [
{ Hook: {
"Flags": t.hsfOVERRIDE,
"CreateCode": "",
}}
]
}, {wallet: account2}).then(x=>
{
console.log(x);
t.assertTxnSuccess(x);
t.api.submit(
{
Account: account2.classicAddress,
TransactionType: "SetHook",
Fee: "100000",
Flags: 0,
Hooks: [
{Hook:{}},
{Hook:{}},
{ Hook: {
HookParameters:
[
{HookParameter: {
HookParameterName: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
HookParameterValue: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB"
}}
]
}}
]
}, {wallet: account2}).then(x=>
{
console.log(x);
t.assertTxnSuccess(x);
console.log("account 1 has the creation: ", account.classicAddress);
console.log("account 2 has the install and delete and update: ", account2.classicAddress);
process.exit(0);
}).catch(t.err);
}).catch(t.err);
}).catch(t.err);
}).catch(t.err);
}).catch(t.err);
}).catch(t.err);
})