@Test public void testChangeNumberPermission() throws Exception { KeyAddress k0 = TestKeys.publicKey(0).getShortAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = "";
@Test public void testSplitJoinPermission() throws Exception { KeyAddress k0 = TestKeys.publicKey(0).getShortAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = "";
KeyAddress k2 = TestKeys.publicKey(2).getShortAddress(); KeyAddress k3 = TestKeys.publicKey(3).getLongAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); String p2 = TestKeys.publicKey(2).packToBase64String(); String p3 = TestKeys.publicKey(3).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = "";
@Test public void testSimpleRoleCheck() throws Exception { KeyAddress k0 = TestKeys.publicKey(0).getShortAddress(); KeyAddress k1 = TestKeys.publicKey(1).getShortAddress(); KeyAddress k2 = TestKeys.publicKey(2).getShortAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); String p2 = TestKeys.publicKey(2).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = ""; js += "print('testSimpleRoleCheck');"; js += "var simpleRole = jsApi.getRoleBuilder().createSimpleRole('owner', '"+k0.toString()+"', '"+k1.toString()+"', '"+k2.toString()+"');"; js += "var check0 = simpleRole.isAllowedForKeys(jsApi.base64toPublicKey('"+p0+"'), jsApi.base64toPublicKey('"+p1+"'));"; js += "var check1 = simpleRole.isAllowedForKeys(jsApi.base64toPublicKey('"+p0+"'), jsApi.base64toPublicKey('"+p1+"'), jsApi.base64toPublicKey('"+p2+"'));"; js += "print('check0: ' + check0);"; js += "print('check1: ' + check1);"; js += "result = [check0, check1];"; JSApiScriptParameters scriptParameters = new JSApiScriptParameters(); contract.getDefinition().setJS(js.getBytes(), "client script.js", scriptParameters); contract.seal(); ScriptObjectMirror res = (ScriptObjectMirror)contract.execJS(js.getBytes()); assertFalse((boolean)res.get("0")); assertTrue((boolean)res.get("1")); }
KeyAddress k2 = TestKeys.publicKey(2).getLongAddress(); KeyAddress k3 = TestKeys.publicKey(3).getShortAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); String p2 = TestKeys.publicKey(2).packToBase64String(); String p3 = TestKeys.publicKey(3).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = "";
KeyAddress k1 = TestKeys.publicKey(1).getShortAddress(); KeyAddress k2 = TestKeys.publicKey(2).getShortAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); String p2 = TestKeys.publicKey(2).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = "";
KeyAddress k2 = TestKeys.publicKey(2).getLongAddress(); KeyAddress k3 = TestKeys.publicKey(3).getLongAddress(); String p0 = TestKeys.publicKey(0).packToBase64String(); String p1 = TestKeys.publicKey(1).packToBase64String(); String p2 = TestKeys.publicKey(2).packToBase64String(); String p3 = TestKeys.publicKey(3).packToBase64String(); Contract contract = new Contract(TestKeys.privateKey(0)); String js = "";