From de433dd540c2c12b9b36e9c5567115446a061498 Mon Sep 17 00:00:00 2001 From: Igor Egorov <36847043+igor-egorov@users.noreply.github.com> Date: Tue, 3 Jul 2018 11:14:07 +0300 Subject: [PATCH] Fix tests for createRole with empty set of permissions (#1520) Signed-off-by: Igor Egorov The behavior of createRole command was changed, so the tests had to be updated. --- shared_model/packages/javascript/tests/txbuilder.js | 2 +- test/module/shared_model/bindings/BuilderTest.java | 7 ++----- test/module/shared_model/bindings/builder-test.py | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/shared_model/packages/javascript/tests/txbuilder.js b/shared_model/packages/javascript/tests/txbuilder.js index af46727baf..9487e81804 100644 --- a/shared_model/packages/javascript/tests/txbuilder.js +++ b/shared_model/packages/javascript/tests/txbuilder.js @@ -128,7 +128,7 @@ test('ModelTransactionBuilder tests', function (t) { validPermissions.set(iroha.Role_kAddPeer) validPermissions.set(iroha.Role_kAddAssetQty) - t.throws(() => correctTx.createRole('new_user_role', emptyPerm).build(), /Permission set should contain at least one permission/, 'Should throw Permission set should contain at least one permission') + t.doesNotThrow(() => correctTx.createRole('new_user_role', emptyPerm).build(), null, 'Should not throw any exceptions') t.throws(() => correctTx.createRole('', validPermissions).build(), /Wrongly formed role_id, passed value: ''/, 'Should throw Wrongly formed role_id') t.throws(() => correctTx.createRole('@@@', validPermissions).build(), /Wrongly formed role_id, passed value: '@@@'/, 'Should throw Wrongly formed role_id') t.throws(() => correctTx.createRole('new_user_role', '').build(), /argument 3 of type 'shared_model::interface::RolePermissionSet/, 'Should throw ...argument 3 of type...') diff --git a/test/module/shared_model/bindings/BuilderTest.java b/test/module/shared_model/bindings/BuilderTest.java index cb72c692a2..c53aa22cdf 100644 --- a/test/module/shared_model/bindings/BuilderTest.java +++ b/test/module/shared_model/bindings/BuilderTest.java @@ -819,11 +819,8 @@ void createRoleWithInvalidName() { @Test void createRoleEmptyPermissions() { - RolePermissionSet permissions = new RolePermissionSet(); - - ModelTransactionBuilder builder = new ModelTransactionBuilder(); - builder.createRole("new_role", permissions); - assertThrows(IllegalArgumentException.class, builder::build); + UnsignedTx tx = builder.createRole("new_role", new RolePermissionSet()).build(); + assertTrue(checkProtoTx(proto(tx))); } /* ====================== DetachRole Tests ====================== */ diff --git a/test/module/shared_model/bindings/builder-test.py b/test/module/shared_model/bindings/builder-test.py index c82ca7175e..f7e6d21b4b 100644 --- a/test/module/shared_model/bindings/builder-test.py +++ b/test/module/shared_model/bindings/builder-test.py @@ -532,8 +532,8 @@ def test_create_role_with_invalid_name(self): self.base().createRole(name, iroha.RolePermissionSet([iroha.Role_kReceive, iroha.Role_kGetRoles])).build() def test_create_role_with_empty_permissions(self): - with self.assertRaises(ValueError): - self.base().createRole("user", iroha.RolePermissionSet([])).build() + tx = self.builder.createRole("user", iroha.RolePermissionSet([])).build() + self.assertTrue(self.check_proto_tx(self.proto(tx))) # ====================== DetachRole Tests ======================