@0xcert/ethereum-sandbox
Version:
Test server for local running testing of modules on the Ethereum blockchain.
58 lines • 2.88 kB
JavaScript
;
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 spec_1 = require("@hayspec/spec");
const request = require("supertest");
const sandbox_1 = require("../../core/sandbox");
const spec = new spec_1.Spec();
const sandbox = new sandbox_1.Sandbox();
spec.before(() => __awaiter(void 0, void 0, void 0, function* () {
yield sandbox.listen({ port: 8010, blockTime: 1 });
}));
spec.after(() => __awaiter(void 0, void 0, void 0, function* () {
yield sandbox.close();
}));
spec.test('listens for requests', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
const res = yield request('http://localhost:8010').get('/').catch((e) => e.response);
ctx.is(res.status, 400);
}));
spec.test('deploys protocol contracts', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
ctx.true(!!sandbox.protocol.erc20);
ctx.true(!!sandbox.protocol.erc721Enumerable);
ctx.true(!!sandbox.protocol.erc721Metadata);
ctx.true(!!sandbox.protocol.erc721);
ctx.true(!!sandbox.protocol.xcertDestroyable);
ctx.true(!!sandbox.protocol.xcertMutable);
ctx.true(!!sandbox.protocol.xcertPausable);
ctx.true(!!sandbox.protocol.xcertRevokable);
ctx.true(!!sandbox.protocol.xcert);
ctx.true(!!sandbox.protocol.xcertCreateProxy);
ctx.true(!!sandbox.protocol.tokenTransferProxy);
ctx.true(!!sandbox.protocol.nftokenTransferProxy);
ctx.true(!!sandbox.protocol.nftokenSafeTransferProxy);
ctx.true(!!sandbox.protocol.nftokenReceiver);
ctx.true(!!sandbox.protocol.actionsGateway);
ctx.true(!!sandbox.protocol.xcertDeployGateway);
ctx.true(!!sandbox.protocol.tokenDeployGateway);
ctx.true(!!sandbox.protocol.abilitableManageProxy);
ctx.true(!!sandbox.protocol.dappToken);
}));
spec.test('subscribes to `newBlockHeaders` event', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
let count = 0;
yield new Promise((resolve) => {
const subscription = sandbox.web3.eth.subscribe('newBlockHeaders');
subscription.on('data', () => count++);
setTimeout(() => resolve(null), 4800);
});
ctx.is(count, 4);
}));
exports.default = spec;
//# sourceMappingURL=sandbox.test.js.map