openvibers/openvibe.network Commits

Grants: bench.judgement.cast for Codes and Run (races as matches) (#900)

OP OpenVibers committed 5 h ago · 7db7f014e4 · 2 files, +19 −0

Changes

ddiff --git a/server/identity/principals.js b/server/identity/principals.js
iindex dbd6b02d..1ad3327c 100644
---- a/server/identity/principals.js
++++ b/server/identity/principals.js
@@@ -802,6 +802,9 @@ const DEFAULT_GRANTS = [
['exchange', 'bench.round.create', 'openvibe.bench', []],
['exchange', 'bench.judgement.cast', 'openvibe.bench', []],
['exchange', 'bench.board.read', 'openvibe.bench', []],
++ // The evaluation loop (compare-arena-ecosystem.md, Contracts 0.422.0): Codes records its races (tests, then the merge)
++ // and Run records the Arena's race plays as bench.match@1 at Bench's POST /api/v1/matches.
++ ...['codes', 'run'].map((svc) => [svc, 'bench.judgement.cast', 'openvibe.bench', []]),
// OpenVibe.Fun (contracts 0.236.0): its public quests and plans in Search through the owner API (owner fun), and
// its account-event subscriptions; its export/deletion pair is above. Live and Chat are public reads and Today
// uses the viewer's own token, so it holds no Live, Chat or Today grant. The optional OpenCoin grants
ddiff --git a/test/bench-matches-grant.test.js b/test/bench-matches-grant.test.js
nnew file mode 100644
iindex 00000000..c1fb1122
---- /dev/null
++++ b/test/bench-matches-grant.test.js
@@@ -0,0 +1,16 @@
++/**
++ * The evaluation loop (Contracts 0.422.0): Codes records its races and Run the Arena's race plays as bench.match@1 at
++ * Bench's POST /api/v1/matches, which takes bench.judgement.cast on audience openvibe.bench.
++ *
++ * node test/bench-matches-grant.test.js
++ */
++'use strict';
++const assert = require('assert');
++const contracts = require('openvibe-contracts');
++const principals = require('../server/identity/principals');
++
++const has = (svc, cap, aud) => principals.DEFAULT_GRANTS.some((g) => g[0] === svc && g[1] === cap && g[2] === aud);
++for (const svc of ['codes', 'run']) assert.ok(has(svc, 'bench.judgement.cast', 'openvibe.bench'), `${svc} records matches on Bench`);
++const cap = contracts.capabilities.get('bench.judgement.cast');
++assert.ok(cap && cap.status === 'active' && cap.owner === 'bench', 'bench.judgement.cast is an active Bench capability');
++console.log('bench matches grant: ok');