Skip to content

Commit 564818d

Browse files
author
francois branciard
committed
Fix #20 add range on trust param 0- 100
1 parent ed214c5 commit 564818d

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Features:
99

1010
Bugfixes:
1111
* [#15](https://github.com/iExecBlockchainComputing/PoCo/issues/15): Malicious IexecAPI contract without callback [PLANNED in v1.0.13]
12-
* [#20](https://github.com/iExecBlockchainComputing/PoCo/issues/20): add range on trust param ( 0- n ) and check it in contracts [PLANNED in v1.0.13]
12+
1313

1414
### v1.0.13 (unreleased)
1515

@@ -19,6 +19,7 @@ Features:
1919

2020
Bugfixes:
2121
* [#24](https://github.com/iExecBlockchainComputing/PoCo/issues/24) possibly useless RLC address getter
22+
* [#20](https://github.com/iExecBlockchainComputing/PoCo/issues/20): add range on trust param ( 0- 100 ) and check it in contracts
2223

2324

2425
### [v1.0.12](https://github.com/iExecBlockchainComputing/PoCo/releases/tag/v1.0.12)

contracts/Marketplace.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ contract Marketplace is IexecHubAccessor
4747
{
4848
require(iexecHubInterface.existingCategory(_category));
4949
require(_volume >0);
50+
require(_trust <=100);
5051
m_orderCount = m_orderCount.add(1);
5152
IexecLib.MarketOrder storage marketorder = m_orderBook[m_orderCount];
5253
marketorder.direction = _direction;

test/byFunctions/Marketplace/createMarketOrder.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ contract('IexecHub', function(accounts) {
478478
});
479479

480480
it("createMarketOrder_10 : a owner (scheduleProvider) of worker pool can't emit a ASK Market Order with volume = 0", async function() {
481-
await Extensions.expectedExceptionPromise(() => {
481+
return await Extensions.expectedExceptionPromise(() => {
482482
return aMarketplaceInstance.createMarketOrder(
483483
constants.MarketOrderDirectionEnum.ASK,
484484
1 /*_category*/ ,
@@ -599,9 +599,48 @@ contract('IexecHub', function(accounts) {
599599

600600
});
601601

602-
/*
603-
TODO trust value tests ?
604-
*/
602+
it("createMarketOrder_13 : a owner (scheduleProvider) of worker pool can emit with _trust <= 100 ", async function() {
603+
604+
txMined = await aMarketplaceInstance.createMarketOrder(
605+
constants.MarketOrderDirectionEnum.ASK,
606+
1 /*_category*/ ,
607+
100 /*_trust*/ ,
608+
0 /*_value*/ ,
609+
workerPoolAddress /*_workerpool of scheduler*/ ,
610+
1 /*_volume*/ , {
611+
from: scheduleProvider
612+
});
613+
614+
events = await Extensions.getEventsPromise(aMarketplaceInstance.MarketOrderCreated({}), 1, constants.EVENT_WAIT_TIMEOUT);
615+
assert.strictEqual(events[0].args.marketorderIdx.toNumber(), 1, "marketorderIdx");
616+
617+
[direction, category, trust, value, volume, remaining, workerpool, workerpoolOwner] = await aMarketplaceInstance.getMarketOrder.call(1);
618+
assert.strictEqual(direction.toNumber(), constants.MarketOrderDirectionEnum.ASK, "check constants.MarketOrderDirectionEnum.ASK");
619+
assert.strictEqual(category.toNumber(), 1, "check category");
620+
assert.strictEqual(trust.toNumber(), 100, "check trust 100");
621+
assert.strictEqual(value.toNumber(), 0, "check value");
622+
assert.strictEqual(volume.toNumber(), 1, "check volume");
623+
assert.strictEqual(remaining.toNumber(), 1, "check remaining");
624+
assert.strictEqual(workerpool, workerPoolAddress, "check workerpool");
625+
assert.strictEqual(workerpoolOwner, scheduleProvider, "check workerpoolOwner");
626+
627+
return await Extensions.expectedExceptionPromise(() => {
628+
return aMarketplaceInstance.createMarketOrder(
629+
constants.MarketOrderDirectionEnum.ASK,
630+
1 /*_category*/ ,
631+
101 /*_trust*/ ,
632+
0 /*_value*/ ,
633+
workerPoolAddress /*_workerpool of scheduler*/ ,
634+
1 /*_volume*/ , {
635+
from: scheduleProvider,
636+
gas: constants.AMOUNT_GAS_PROVIDED
637+
});
638+
},
639+
constants.AMOUNT_GAS_PROVIDED);
640+
641+
642+
});
643+
605644

606645

607646
});

0 commit comments

Comments
 (0)