Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Remove solidity cases from oasis-client tests #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 45 additions & 59 deletions test/8_test_oasis_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ const utils = require('../src/utils');
if (truffleConfig.shouldRun(__filename)) {
contract('Oasis client', async (accounts) => {
const services = [
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only two changes here removing this case and...

idl: Counter.abi,
bytecode: Counter.bytecode,
coder: new oasis.utils.EthereumCoder(),
label: 'solidity'
},
{
idl: undefined,
bytecode: require('fs').readFileSync(
Expand Down Expand Up @@ -53,69 +47,61 @@ if (truffleConfig.shouldRun(__filename)) {
gateways.forEach(gatewayConfig => {
services.forEach(serviceConfig => {
headers.forEach(headerConfig => {
// We don't support confidential solidity.
if (!headerConfig.header.confidential || serviceConfig.label !== 'solidity') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing this if statement.

let prefix = `${serviceConfig.label}/${gatewayConfig.label}/${headerConfig.label}`;
let service;
let prefix = `${serviceConfig.label}/${gatewayConfig.label}/${headerConfig.label}`;
let service;

it(`${prefix}: sets the default gateway`, () => {
oasis.setGateway(gatewayConfig.gateway);
});
it(`${prefix}: sets the default gateway`, () => {
oasis.setGateway(gatewayConfig.gateway);
});

it(`${prefix}: deploys a service`, async () => {
service = await oasis.deploy({
idl: serviceConfig.idl,
bytecode: serviceConfig.bytecode,
arguments: [],
header: headerConfig.header,
coder: serviceConfig.coder
});
it(`${prefix}: deploys a service`, async () => {
service = await oasis.deploy({
idl: serviceConfig.idl,
bytecode: serviceConfig.bytecode,
arguments: [],
header: headerConfig.header,
coder: serviceConfig.coder
});
});

it(`${prefix}: executes an rpc`, async () => {
let beforeCount = await service.get_counter(gatewayConfig.options);
await service.increment_counter(gatewayConfig.options);
let afterCount = await service.get_counter(gatewayConfig.options);
await service.set_counter(6, gatewayConfig.options);
let afterSetCount = await service.get_counter(gatewayConfig.options);
await service.set_counter2(10, 9, gatewayConfig.options);
let afterSetCount2 = await service.get_counter(gatewayConfig.options);
it(`${prefix}: executes an rpc`, async () => {
let beforeCount = await service.get_counter(gatewayConfig.options);
await service.increment_counter(gatewayConfig.options);
let afterCount = await service.get_counter(gatewayConfig.options);
await service.set_counter(6, gatewayConfig.options);
let afterSetCount = await service.get_counter(gatewayConfig.options);
await service.set_counter2(10, 9, gatewayConfig.options);
let afterSetCount2 = await service.get_counter(gatewayConfig.options);

assert.equal(beforeCount, 0);
assert.equal(afterCount, 1);
assert.equal(afterSetCount, 6);
assert.equal(afterSetCount2, 9);
});
assert.equal(beforeCount, 0);
assert.equal(afterCount, 1);
assert.equal(afterSetCount, 6);
assert.equal(afterSetCount2, 9);
});

it(`${prefix}: listens for three service events`, async () => {
let logs = await new Promise(async resolve => {
let logs = [];
service.addEventListener('Incremented', function listener (event) {
logs.push(event);
if (logs.length === 3) {
service.removeEventListener('Incremented', listener);
resolve(logs);
}
});
for (let k = 0; k < 3; k += 1) {
await service.increment_counter(gatewayConfig.options);
it(`${prefix}: listens for three service events`, async () => {
let logs = await new Promise(async resolve => {
let logs = [];
service.addEventListener('Incremented', function listener (event) {
logs.push(event);
if (logs.length === 3) {
service.removeEventListener('Incremented', listener);
resolve(logs);
}
});

for (let k = 1; k < logs.length; k += 1) {
// Depending upon the gateway's view, we might get the log for the previous test,
// so just ensure the logs received are monotonically increasing.
let currentCounter = logs[k].newCounter;
let lastCounter = logs[k - 1].newCounter;
// Solidity coder uses big numbers.
if (serviceConfig.label === 'solidity') {
currentCounter = currentCounter.toNumber();
lastCounter = lastCounter.toNumber();
}
assert.equal(currentCounter - lastCounter, 1);
for (let k = 0; k < 3; k += 1) {
await service.increment_counter(gatewayConfig.options);
}
});
}

for (let k = 1; k < logs.length; k += 1) {
// Depending upon the gateway's view, we might get the log for the previous test,
// so just ensure the logs received are monotonically increasing.
let currentCounter = logs[k].newCounter;
let lastCounter = logs[k - 1].newCounter;
assert.equal(currentCounter - lastCounter, 1);
}
});
});
});
});
Expand Down