# Copyright 2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ ? pragma.syntax("0.9") > pragma.enable("accumulator") ? var i := 10000000 > def pseudoEntropy { > to nextSwiss() { return (i += 1) } > } > /** start a new series */ > def resetEntropy() { i := (i // 10000000 + 1) * 10000000 } > null ? def makeIntroducer :DeepFrozen := # value: The introducer has two irreversible state changes: becoming identified (newVatIdentity or setVatIdentity) and going on the air (onTheAir). We shall use the first instance to test the case of newVatIdentity followed by onTheAir. ? def [introducer, identityMgr, ] := makeIntroducer.makePair([].asMap(), pseudoEntropy, def fakeTimer {}) # value: [, , ] Get/information operations, off the air: ? def locatorUnum := introducer.getLocatorUnum() # value: ? introducer.getNetConfig() # problem: XXX no net config object yet ? introducer.getVatID() # problem: introducer not yet identified ? introducer.hasIdentity() # value: false ? introducer.isOnTheAir() # value: false ? introducer.negotiable() # value: ["BOGUS_PLACEHOLDER"] XXX have some real values SturdyRef operations work even when off the air, except for the ref's getRcvr. Basic string/SturdyRef conversions: ? def sr := .sturdyFromURI("captp://*gehdu662wssibp5lmuxmiwqkpadeign6@192.168.0.6:60334/jctrw2x2nejbk3bfsneugza5ub2korsd") # value: ? sr.getRcvr() # problem: introducer not yet identified ? sr == ["//*gehdu662wssibp5lmuxmiwqkpadeign6@192.168.0.6:60334/jctrw2x2nejbk3bfsneugza5ub2korsd"] # value: true ? .sturdyToURI(sr) # value: "captp://*gehdu662wssibp5lmuxmiwqkpadeign6@192.168.0.6:60334/jctrw2x2nejbk3bfsneugza5ub2korsd" ? .optUnget(sr) # value: "//*gehdu662wssibp5lmuxmiwqkpadeign6@192.168.0.6:60334/jctrw2x2nejbk3bfsneugza5ub2korsd" ? .optUncall(sr) # value: [, "get", ["//*gehdu662wssibp5lmuxmiwqkpadeign6@192.168.0.6:60334/jctrw2x2nejbk3bfsneugza5ub2korsd"]] ? .optUnget("foo") ? .optUncall("foo") URI parsing errors, rejection, etc. ? .sturdyFromURI("gobbledegook") # problem: Malformed CapTP URI: expected "captp"... ($-hole 0), found "gobbledegook" ? .sturdyFromURI("captp://foo") # problem: Malformed CapTP URI: expected "//*"..., found "//foo" ? .sturdyFromURI("captp://*foo") # problem: Malformed CapTP URI: expected "@"..., found foo ? .sturdyFromURI("captp://*foo@bar") # problem: Malformed CapTP URI: expected "/"..., found bar ? .sturdyFromURI("captp://*foo@bar/") # problem: Malformed CapTP URI: $ was false for []> XXX poorly phrased error ? .sturdyFromURI("captp://*foo@bar/baz") # problem: Malformed CapTP URI: invalid base32: nonzero padding ? .sturdyFromURI("captp://*aa@bar/baz") # problem: Malformed CapTP URI: invalid base32: nonzero padding ? .sturdyFromURI("captp://*aa@bar/aa") # value: ? .sturdyFromURI("captp://*0@bar/0") # problem: Malformed CapTP URI: Not a base32 character: 0 ? .sturdyFromURI("captp://*0@bar/aa") # value: ? .sturdyFromURI("captp://*aa@bar/0") # problem: Malformed CapTP URI: Not a base32 character: 0 IdentityMgr, off the air: ? identityMgr.makeKnown(40) # problem: introducer not yet identified XXX explain why this doesn't succeed ... XXX other operations ------------------------------------------------------------------------------ Becoming identified ? def keyPair_first := introducer.newVatIdentity() # value: ? introducer # value: ? introducer.newVatIdentity() # problem: is already identified ? introducer.setVatIdentity(keyPair_first) # problem: is already identified ? introducer.getNetConfig() # problem: XXX no net config object yet ? def vatID_first :String := introducer.getVatID(); null ? introducer.hasIdentity() # value: true ? introducer.isOnTheAir() # value: false ? sr.getRcvr() # problem: Must first be onTheAir ? locatorUnum.getRcvr([], "outside2", 1234, null) # problem: Must first be onTheAir XXX test local sturdyrefs, identityMgr at this point ------------------------------------------------------------------------------ Going on the air ? introducer.onTheAir() # value: ["BOGUS_PLACEHOLDER"] ? introducer.onTheAir() # idempotent # value: ["BOGUS_PLACEHOLDER"] ? introducer # value: Introducer, on the air: ? introducer.getNetConfig() # problem: XXX no net config object yet ? introducer.getVatID() == vatID_first # value: true ? introducer.hasIdentity() # value: true ? introducer.isOnTheAir() # value: true ? introducer.negotiable() # value: ["BOGUS_PLACEHOLDER"] IdentityMgr, on the air: XXX srLocal :SturdyRef1 ? def [srLocal, timeout, swissBase] := identityMgr.makeKnown(40) # value: [, , 10000003] ? .optUnget(srLocal).replaceAll(vatID_first, "vid") # value: "//*vid@/bbdp6dt6i4erul4fp575vvsdwk4i2rob" Local SturdyRef, on the air: ? srLocal.getRcvr() # value: 40 XXX this matches EoJ (value is available immediately); but do we want to expose that the ref is local? (if not, then "to 40" print must be removed too) ? locatorUnum.getRcvr([], introducer.getVatID(), swissBase.cryptoHash(), null) # value: 40 ------------------------------------------------------------------------------ This instance will be used to test onTheAir/0 without having set an identity first (in which case an identity is generated, but not revealed). ? resetEntropy() > def [introducer, identityMgr, ] := makeIntroducer.makePair([].asMap(), pseudoEntropy, def fakeTimer {}) # value: [, , ] ? introducer.onTheAir() # value: ["BOGUS_PLACEHOLDER"] ? introducer.onTheAir() # idempotent # value: ["BOGUS_PLACEHOLDER"] ? introducer.isOnTheAir() # value: true ? introducer.hasIdentity() # value: true (Testing that this doesn't fail.) ? identityMgr.makeKnown(38372) # value: [, , 20000002] ? def vatID_second :String := introducer.getVatID() > vatID_second != vatID_first # value: true ------------------------------------------------------------------------------ This instance is given the identity of the first, and we confirm that it produces the same VatID. ? resetEntropy() > def [introducer, identityMgr, ] := makeIntroducer.makePair([].asMap(), pseudoEntropy, def fakeTimer {}) # value: [, , ] ? introducer.setVatIdentity(keyPair_first) ? introducer.getVatID() == vatID_first # value: true ------------------------------------------------------------------------------ XXX operations to test: setVatIdentity/1 with a known keypair and confirm that the VatID etc. is as expected getNetConfig/0 setNetConfig/1 setReferenceMonitor/1 setVatIdentity/1 XXX test all identityMgr operations