From 7cec370e1e20ef30c77aafc4c773c88fe541e428 Mon Sep 17 00:00:00 2001 From: Andrei Lebedev Date: Sat, 19 Aug 2017 23:13:52 +0300 Subject: [PATCH] Add test for CreateDomain --- .../model/command_validate_execute_test.cpp | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/test/module/irohad/model/command_validate_execute_test.cpp b/test/module/irohad/model/command_validate_execute_test.cpp index a5735a58fe..c91d10fe75 100644 --- a/test/module/irohad/model/command_validate_execute_test.cpp +++ b/test/module/irohad/model/command_validate_execute_test.cpp @@ -22,6 +22,7 @@ #include "model/commands/assign_master_key.hpp" #include "model/commands/create_account.hpp" #include "model/commands/create_asset.hpp" +#include "model/commands/create_domain.hpp" #include "model/commands/remove_signatory.hpp" #include "model/commands/set_permissions.hpp" #include "model/commands/set_quorum.hpp" @@ -437,6 +438,37 @@ TEST_F(CreateAssetTest, InvalidWhenNoPermissions) { } +class CreateDomainTest : public CommandValidateExecuteTest { + public: + void SetUp() override { + CommandValidateExecuteTest::SetUp(); + + create_domain = std::make_shared(); + create_domain->domain_name = "CN"; + + command = create_domain; + } + + std::shared_ptr create_domain; +}; + +TEST_F(CreateDomainTest, ValidWhenCreatorHasPermissions) { + // Creator is money creator + creator.permissions.create_domains = true; + + EXPECT_CALL(*wsv_command, insertDomain(_)).WillOnce(Return(true)); + + ASSERT_TRUE(validateAndExecute()); +} + +TEST_F(CreateDomainTest, InvalidWhenNoPermissions) { + // Creator has no permissions + creator.permissions.create_domains = false; + + ASSERT_FALSE(validateAndExecute()); +} + + class RemoveSignatoryTest : public CommandValidateExecuteTest { public: void SetUp() override { @@ -758,4 +790,4 @@ TEST_F(TransferAssetTest, InvalidWhenZeroAmount) { ASSERT_FALSE(validateAndExecute()); } -// TODO AddDomain and AddPeer tests +