Skip to content

Commit b5ec68e

Browse files
committed
More CNS refinement
1 parent f62f997 commit b5ec68e

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

convex-core/src/main/cvx/convex/core/registry.cvx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
:doc {:description "Creates a CNS entry with given reference, controller and metadata"
121121
:examples [{:code "(*registry*/create 'my.actor.name target *address* {:some :metadata})"}]
122122
:signature [{:params [sym]}]}}
123-
124123
([sym] (recur sym nil *address* nil nil))
125124
([sym addr] (recur sym addr *address* nil nil))
126125
([sym addr cont] (recur sym addr cont nil nil))
@@ -149,15 +148,14 @@
149148
(recur (inc i) nref)))
150149
))
151150
)
152-
)
153-
sym
154-
))
151+
;; TODO: Not clear what default return value should be? [~*address* path]?
152+
)))
155153

156154
(defn control
157155
[sym cont]
158156
(if-let [rec (read sym)]
159157
(let [[v c m child] rec]
160-
(update sym v cont m))
158+
(update sym v cont m child))
161159
(fail :STATE "CNS record does not exist")))
162160

163161

convex-core/src/main/java/convex/core/init/Init.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private static State addStandardLibraries(State s) {
341341

342342
private static State addCNSTree(State s) {
343343
Context ctx=Context.create(s, GOVERNANCE_ADDRESS);
344-
ctx=ctx.eval(Reader.read("(*registry*/create 'cns *registry*)"));
344+
ctx=ctx.eval(Reader.read("(*registry*/create 'convex.cns *registry*)"));
345345
ctx.getResult();
346346

347347
// check we can get access to general trust monitors

convex-core/src/test/java/convex/lib/CNSTest.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class CNSTest extends ACVMTest {
3333
@Test public void testConstantSetup() {
3434
assertEquals(Init.REGISTRY_ADDRESS,eval("*registry*"));
3535
assertEquals(Init.REGISTRY_ADDRESS,eval("cns"));
36-
assertEquals(Init.REGISTRY_ADDRESS,eval("(*registry*/resolve 'cns)"));
36+
assertEquals(Init.REGISTRY_ADDRESS,eval("@convex.registry"));
3737

3838
// TODO: fix this
3939
// assertEquals(Init.REGISTRY_ADDRESS,eval("@cns"));
@@ -46,6 +46,7 @@ public class CNSTest extends ACVMTest {
4646
}
4747

4848
@Test public void testTrust() {
49+
// Root CNS node should only trust governance account
4950
assertFalse(evalB("(trust/trusted? [cns []] *address*)"));
5051
assertTrue(evalB("(query-as #6 `(~trust/trusted? [~cns []] *address*))"));
5152
}
@@ -70,26 +71,26 @@ public class CNSTest extends ACVMTest {
7071
// HERO shouldn't be able to create a top level CNS entry
7172
assertTrustError(step("(*registry*/create 'foo)"));
7273

73-
// INIT should be able to create a top level CNS entry
74-
Context ictx=context().forkWithAddress(Init.GOVERNANCE_ADDRESS);
75-
ictx=step(ictx,"(import convex.trust :as trust)");
76-
ictx=(step(ictx,"(*registry*/create 'foo #17)"));
77-
assertNotError(ictx);
78-
ictx=step(ictx,"(def ref [*registry* [\"foo\"]])");
79-
AVector<?> ref=ictx.getResult();
74+
// NEed governance address to be able to create a top level CNS entry
75+
Context ctx=context().forkWithAddress(Init.GOVERNANCE_ADDRESS);
76+
ctx=step(ctx,"(import convex.trust :as trust)");
77+
ctx=(step(ctx,"(*registry*/create 'foo #17)"));
78+
assertNotError(ctx);
79+
ctx=step(ctx,"(def ref [*registry* [\"foo\"]])");
80+
AVector<?> ref=ctx.getResult();
8081
assertNotNull(ref);
8182

8283
// System.out.println(eval(ictx,"*registry*/cns-database"));
8384

84-
assertEquals(Address.create(17),eval(ictx,"(*registry*/resolve 'foo)"));
85+
assertEquals(Address.create(17),eval(ctx,"(*registry*/resolve 'foo)"));
8586

86-
ictx=(step(ictx,"(*registry*/create 'foo #666)"));
87-
assertEquals(Address.create(666),eval(ictx,"(*registry*/resolve 'foo)"));
87+
ctx=(step(ctx,"(*registry*/create 'foo #666)"));
88+
assertEquals(Address.create(666),eval(ctx,"(*registry*/resolve 'foo)"));
8889

8990
// HERO still shouldn't be able to update a top level CNS entry
90-
ictx=ictx.forkWithAddress(HERO);
91-
assertTrustError(step(ictx,"(*registry*/create 'foo *address* *address* {})"));
92-
assertTrustError(step(ictx,"(trust/change-control "+ref+" *address*)"));
91+
ctx=ctx.forkWithAddress(HERO);
92+
assertTrustError(step(ctx,"(*registry*/create 'foo *address* *address* {})"));
93+
assertTrustError(step(ctx,"(trust/change-control "+ref+" *address*)"));
9394

9495
}
9596

0 commit comments

Comments
 (0)