Skip to content

Commit

Permalink
Add test for CreateDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
lebdron committed Aug 22, 2017
1 parent b5795ac commit 7cec370
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion test/module/irohad/model/command_validate_execute_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -437,6 +438,37 @@ TEST_F(CreateAssetTest, InvalidWhenNoPermissions) {
}


class CreateDomainTest : public CommandValidateExecuteTest {
public:
void SetUp() override {
CommandValidateExecuteTest::SetUp();

create_domain = std::make_shared<CreateDomain>();
create_domain->domain_name = "CN";

command = create_domain;
}

std::shared_ptr<CreateDomain> 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 {
Expand Down Expand Up @@ -758,4 +790,4 @@ TEST_F(TransferAssetTest, InvalidWhenZeroAmount) {
ASSERT_FALSE(validateAndExecute());
}

// TODO AddDomain and AddPeer tests

0 comments on commit 7cec370

Please sign in to comment.