45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
|
|
import {root} from 'proto'
|
|
import { connect, ServiceContext } from '../src/ServiceContext'
|
|
import { DynamicService, fillDefaults, fixupEnums } from "../src/DynamicService"
|
|
|
|
test.skip('fill defaults', () => {
|
|
let tname = "SyntheticContract"
|
|
const Data = root.lookupType(tname)
|
|
const inst = Data.create({})
|
|
fillDefaults(tname, inst)
|
|
console.log(inst)
|
|
})
|
|
|
|
test('log in and say hi', async () => {
|
|
let ctx = await connect("bts", "");
|
|
expect(ctx instanceof ServiceContext).toBe(true)
|
|
const admin = new DynamicService(<ServiceContext>ctx, "AdminService", "", [
|
|
["get_admin_data", 16, "bts.api.VoidMessage", "bts.api.admin.AdminData"],
|
|
["update_account", 1, "bts.api.admin.AccountUpdateAPIArgument", "bts.api.admin.AdminServiceOperationResult"]
|
|
]);
|
|
const adminData = await admin.get_admin_data({})
|
|
const account1 = adminData.accounts[2]
|
|
const dat = account1.exchangeAccountData
|
|
console.log(dat)
|
|
let dattype = root.lookupType("ExchangeAccountData")
|
|
let dat2 = fixupEnums(dat, dattype)
|
|
console.log(dat2)
|
|
// const result = await admin.update_account({ completeData: account1 })
|
|
// console.log(result.errorText)
|
|
// for (let x in clip) {
|
|
// console.log(x)
|
|
// }
|
|
// console.log(JSON.stringify( clip))
|
|
// console.log(result)
|
|
}, 15000);
|
|
|
|
test.skip('api_errors_updated', () => {
|
|
const ResponseHeader = root.lookupType("bts.api.AdminData")
|
|
const rh = ResponseHeader.encode({ }).finish()
|
|
const round = ResponseHeader.decode(rh)
|
|
expect(round).toBeDefined()
|
|
});
|
|
|
|
|