"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const ts_mockito_1 = require("ts-mockito");
const models_1 = require("../../models");
const services_1 = require("../../services");
const tx_1 = require("./tx");
let mockConnectionService = ts_mockito_1.mock(services_1.ConnectionService);
beforeEach(() => {
    ts_mockito_1.reset(mockConnectionService);
});
describe('tx', () => {
    it('postCreate', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postCreate(ts_mockito_1.instance(mockConnectionService), { txType: 'encumber' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ txType: 'encumber' }), ts_mockito_1.deepEqual(models_1.apiConfig.txCreate))).once();
        expect(result).toBe('result');
    }));
    it('postEncumber', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postEncumber(ts_mockito_1.instance(mockConnectionService), { address: 'add', administrators: [{ address: 'add', startTime: 1, endTime: 2 }], amount: 100, beneficiaries: [{ address: 'add2', startTime: 3, endTime: 4 }], namespace: 'BOE', classId: 'GBP', reference: 'ref', timestamp: 100, walletId: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add', administrators: [{ address: 'add', startTime: 1, endTime: 2 }], amount: 100, beneficiaries: [{ address: 'add2', startTime: 3, endTime: 4 }], namespace: 'BOE', classId: 'GBP', reference: 'ref', timestamp: 100, walletId: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.txEncumber))).once();
        expect(result).toBe('result');
    }));
    it('postExerciseEncumbrance', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postExerciseEncumbrance(ts_mockito_1.instance(mockConnectionService), { address: 'add', amount: 100, namespace: 'BOE', classId: 'GBP' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add', amount: 100, namespace: 'BOE', classId: 'GBP' }), ts_mockito_1.deepEqual(models_1.apiConfig.txExerciseEncumbrance))).once();
        expect(result).toBe('result');
    }));
    it('postIssueAsset', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postIssueAsset(ts_mockito_1.instance(mockConnectionService), { amount: 100, namespace: 'BOE', classId: 'GBP', fromAddress: 'add1', toAddress: 'add2', walletId: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ amount: 100, namespace: 'BOE', classId: 'GBP', fromAddress: 'add1', toAddress: 'add2', walletId: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.txIssueAsset))).once();
        expect(result).toBe('result');
    }));
    it('postIssuerTransfer', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postIssuerTransfer(ts_mockito_1.instance(mockConnectionService), { amount: 100, namespace: 'BOE', classId: 'GBP', fromAddress: 'add1', toAddress: 'add2' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ amount: 100, namespace: 'BOE', classId: 'GBP', fromAddress: 'add1', toAddress: 'add2' }), ts_mockito_1.deepEqual(models_1.apiConfig.txIssuerTransfer))).once();
        expect(result).toBe('result');
    }));
    it('postIssuerTransfer', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postIssuerTransfer(ts_mockito_1.instance(mockConnectionService), { amount: 100, namespace: 'BOE', classId: 'GBP', fromAddress: 'add1', toAddress: 'add2' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ amount: 100, namespace: 'BOE', classId: 'GBP', fromAddress: 'add1', toAddress: 'add2' }), ts_mockito_1.deepEqual(models_1.apiConfig.txIssuerTransfer))).once();
        expect(result).toBe('result');
    }));
    it('postNull', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postNull(ts_mockito_1.instance(mockConnectionService), { address: 'add', walletId: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add', walletId: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.txNull))).once();
        expect(result).toBe('result');
    }));
    it('postRegisterAsset', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postRegisterAsset(ts_mockito_1.instance(mockConnectionService), { address: 'add', namespace: 'BOE', classId: 'GBP', walletId: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add', walletId: 1, namespace: 'BOE', classId: 'GBP' }), ts_mockito_1.deepEqual(models_1.apiConfig.txRegisterAsset))).once();
        expect(result).toBe('result');
    }));
    it('postRegisterNamespace', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postRegisterNamespace(ts_mockito_1.instance(mockConnectionService), { address: 'add', namespace: 'BOE', walletid: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add', walletid: 1, namespace: 'BOE' }), ts_mockito_1.deepEqual(models_1.apiConfig.txRegisterNamespace))).once();
        expect(result).toBe('result');
    }));
    it('postTransferAsset', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postTransferAsset(ts_mockito_1.instance(mockConnectionService), { walletId: 1, fromAddress: 'add1', toAddress: 'add2', namespace: 'BOE', classId: 'GBP', amount: 100 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ walletId: 1, fromAddress: 'add1', toAddress: 'add2', namespace: 'BOE', classId: 'GBP', amount: 100 }), ts_mockito_1.deepEqual(models_1.apiConfig.txTransferAsset))).once();
        expect(result).toBe('result');
    }));
    it('postTransferFromMany', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postTransferFromMany(ts_mockito_1.instance(mockConnectionService), { walletId: 1, address: 'add', namespace: 'BOE', classId: 'GBP', amount: 100, transfers: [] });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ walletId: 1, address: 'add', namespace: 'BOE', classId: 'GBP', amount: 100, transfers: [] }), ts_mockito_1.deepEqual(models_1.apiConfig.txTransferFromMany))).once();
        expect(result).toBe('result');
    }));
    it('postUnencumber', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield tx_1.postUnencumber(ts_mockito_1.instance(mockConnectionService), { walletId: 1, address: 'add', namespace: 'BOE', classId: 'GBP', amount: 100, reference: 'ref', timestamp: 100 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ walletId: 1, address: 'add', namespace: 'BOE', classId: 'GBP', amount: 100, reference: 'ref', timestamp: 100 }), ts_mockito_1.deepEqual(models_1.apiConfig.txUnencumber))).once();
        expect(result).toBe('result');
    }));
});
