From 2936f76e4b35b279aa5c31ce8b3ceaa5265e096c Mon Sep 17 00:00:00 2001 From: BSMaidSafe Date: Tue, 24 Feb 2015 15:29:47 +0000 Subject: [PATCH 1/5] MaidManager tests. --- .../vault/tests/maid_manager_account_test.cc | 169 ++++++++++++++++++ src/maidsafe/vault/tests/maid_manager_test.cc | 167 +++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100644 src/maidsafe/vault/tests/maid_manager_account_test.cc create mode 100644 src/maidsafe/vault/tests/maid_manager_test.cc diff --git a/src/maidsafe/vault/tests/maid_manager_account_test.cc b/src/maidsafe/vault/tests/maid_manager_account_test.cc new file mode 100644 index 000000000..3225bf620 --- /dev/null +++ b/src/maidsafe/vault/tests/maid_manager_account_test.cc @@ -0,0 +1,169 @@ +/* Copyright 2012 MaidSafe.net limited + + This MaidSafe Software is licensed to you under (1) the MaidSafe.net Commercial License, + version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which + licence you accepted on initial access to the Software (the "Licences"). + + By contributing code to the MaidSafe Software, or to this project generally, you agree to be + bound by the terms of the MaidSafe Contributor Agreement, version 1.0, found in the root + directory of this project at LICENSE, COPYING and CONTRIBUTOR respectively and also + available at: http://www.maidsafe.net/licenses + + Unless required by applicable law or agreed to in writing, the MaidSafe Software distributed + under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. + + See the Licences for the specific language governing permissions and limitations relating to + use of the MaidSafe Software. */ + +#include "maidsafe/common/test.h" +#include "maidsafe/common/utils.h" + +#include "maidsafe/vault/maid_manager/account.h" + +namespace maidsafe { + +namespace vault { + +namespace test { + + +TEST(MaidManagerAccountTest, BEH_Construct) { + { + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + uint64_t data_stored(1), space_available(1); + MaidManagerAccount account(name, data_stored, space_available); + + ASSERT_EQ(name, account.name()); + ASSERT_EQ(data_stored, account.data_stored()); + ASSERT_EQ(space_available, account.space_available()); + + ASSERT_NO_THROW(MaidManagerAccount account_copy(account)); + ASSERT_NO_THROW(MaidManagerAccount(std::move(account))); + } + { + MaidManagerAccount::AccountName name1(Identity(RandomAlphaNumericString(64))); + uint64_t data1_stored(1), space1_available(1); + MaidManagerAccount account1(name1, data1_stored, space1_available); + + ASSERT_EQ(name1, account1.name()); + ASSERT_EQ(data1_stored, account1.data_stored()); + ASSERT_EQ(space1_available, account1.space_available()); + + MaidManagerAccount::AccountName name2(Identity(RandomAlphaNumericString(64))); + uint64_t data2_stored(2), space2_available(2); + MaidManagerAccount account2(name2, data2_stored, space2_available); + + ASSERT_EQ(name2, account2.name()); + ASSERT_EQ(data2_stored, account2.data_stored()); + ASSERT_EQ(space2_available, account2.space_available()); + + ASSERT_NO_THROW(account2 = account1); + ASSERT_NE(name2, account2.name()); + ASSERT_NE(data2_stored, account2.data_stored()); + ASSERT_NE(space2_available, account2.space_available()); + ASSERT_EQ(account2.name(), account1.name()); + ASSERT_EQ(account2.data_stored(), account1.data_stored()); + ASSERT_EQ(account2.space_available(), account1.space_available()); + } +} + +TEST(MaidManagerAccountTest, BEH_SerialiseParse) { + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + uint64_t data_stored(0), space_available(100); + MaidManagerAccount account1(name, data_stored, space_available); + + ASSERT_EQ(name, account1.name()); + ASSERT_EQ(data_stored, account1.data_stored()); + ASSERT_EQ(space_available, account1.space_available()); + + std::string serialised_account; + ASSERT_NO_THROW(serialised_account = account1.serialise()); + MaidManagerAccount account2(serialised_account); + + ASSERT_EQ(name, account2.name()); + ASSERT_EQ(data_stored, account2.data_stored()); + ASSERT_EQ(space_available, account2.space_available()); +} + +TEST(MaidManagerAccountTest, BEH_EqualityInequality) { + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + uint64_t data_stored(1), space_available(1); + MaidManagerAccount account1(name, data_stored, space_available), + account2(name, data_stored, space_available), + account3(name, data_stored, space_available + 1); + + ASSERT_TRUE(account1 == account2); + ASSERT_FALSE(account1 == account3); + ASSERT_FALSE(account1 != account2); + ASSERT_TRUE(account1 != account3); +} + +TEST(MaidManagerAccountTest, BEH_Ordering) { + MaidManagerAccount::AccountName name1(Identity("A" + RandomAlphaNumericString(63))), + name2(Identity("B" + RandomAlphaNumericString(63))); + uint64_t data_stored(1), space_available(1); + MaidManagerAccount account1(name1, data_stored, space_available), + account2(name2, data_stored, space_available), + account3(name1, data_stored, space_available); + + ASSERT_TRUE(account1 <= account3); + ASSERT_TRUE(account1 >= account3); + ASSERT_FALSE(account1 < account3); + ASSERT_FALSE(account1 > account3); + + ASSERT_TRUE(account1 <= account2); + ASSERT_FALSE(account1 >= account2); + ASSERT_TRUE(account1 < account2); + ASSERT_FALSE(account1 > account2); +} + +TEST(MaidManagerAccountTest, BEH_AllowPut) { + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + uint64_t data_stored(0), space_available(100); + MaidManagerAccount account(name, data_stored, space_available); + + ASSERT_EQ(name, account.name()); + ASSERT_EQ(data_stored, account.data_stored()); + ASSERT_EQ(space_available, account.space_available()); + + passport::Anpmid anpmid; + passport::Pmid pmid(anpmid); + passport::PublicAnpmid public_anpmid(anpmid); + passport::PublicPmid public_pmid(pmid); + + ASSERT_EQ(MaidManagerAccount::Status::kOk, account.AllowPut(public_anpmid)); + ASSERT_EQ(MaidManagerAccount::Status::kOk, account.AllowPut(public_pmid)); + + NonEmptyString content1(RandomString(2)), content2(RandomString(23)), + content3(RandomString(26)); + ImmutableData data1(content1), data2(content2), data3(content3); + + ASSERT_EQ(MaidManagerAccount::Status::kOk, account.AllowPut(data1)); + ASSERT_EQ(MaidManagerAccount::Status::kLowSpace, account.AllowPut(data2)); + ASSERT_EQ(MaidManagerAccount::Status::kNoSpace, account.AllowPut(data3)); +} + +TEST(MaidManagerAccountTest, BEH_PutDelete) { + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + uint64_t data_stored(0), space_available(100); + const uint64_t kSize(100); + MaidManagerAccount account(name, data_stored, space_available); + + ASSERT_EQ(name, account.name()); + ASSERT_EQ(data_stored, account.data_stored()); + ASSERT_EQ(space_available, account.space_available()); + + account.PutData(kSize); + ASSERT_EQ(space_available, account.data_stored()); + ASSERT_EQ(data_stored, account.space_available()); + account.DeleteData(kSize); + ASSERT_EQ(data_stored, account.data_stored()); + ASSERT_EQ(space_available, account.space_available()); +} + +} // namespace test + +} // namespace vault + +} // namespace maidsafe diff --git a/src/maidsafe/vault/tests/maid_manager_test.cc b/src/maidsafe/vault/tests/maid_manager_test.cc new file mode 100644 index 000000000..439f638ef --- /dev/null +++ b/src/maidsafe/vault/tests/maid_manager_test.cc @@ -0,0 +1,167 @@ +/* Copyright 2012 MaidSafe.net limited + + This MaidSafe Software is licensed to you under (1) the MaidSafe.net Commercial License, + version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which + licence you accepted on initial access to the Software (the "Licences"). + + By contributing code to the MaidSafe Software, or to this project generally, you agree to be + bound by the terms of the MaidSafe Contributor Agreement, version 1.0, found in the root + directory of this project at LICENSE, COPYING and CONTRIBUTOR respectively and also + available at: http://www.maidsafe.net/licenses + + Unless required by applicable law or agreed to in writing, the MaidSafe Software distributed + under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. + + See the Licences for the specific language governing permissions and limitations relating to + use of the MaidSafe Software. */ + +#include "maidsafe/common/test.h" +#include "maidsafe/common/utils.h" + +#include "maidsafe/vault/maid_manager/maid_manager.h" +#include "maidsafe/vault/vault.h" + +namespace maidsafe { + +namespace vault { + +namespace test { + + +MaidManager::AccountName CreateAccount(MaidManager& maid_manager, + uint64_t space_offered) { + passport::Anmaid anmaid; + passport::Maid maid(anmaid); + passport::PublicAnmaid public_anmaid(anmaid); + passport::PublicMaid public_maid(maid); + + for (;;) { + try { + maid_manager.HandleCreateAccount(public_maid, public_anmaid, space_offered); + EXPECT_TRUE(maid_manager.HasAccount(public_maid.name())); + break; + } + catch (const maidsafe_error& error) { + EXPECT_EQ(make_error_code(VaultErrors::failed_to_handle_request), error.code()); + EXPECT_FALSE(maid_manager.HasAccount(public_maid.name())); + } + } + + return public_maid.name(); +} + +template +std::pair GetSourceAddressAndData( + const MaidManager::AccountName account_name, uint32_t data_size) { + Data data(NonEmptyString(RandomAlphaNumericString(data_size))); + + auto node_address(routing::NodeAddress(routing::Address(account_name.value))); + auto group_address = boost::optional(); + auto reply_to_address = boost::optional(); + auto source_address(routing::SourceAddress(node_address, group_address, reply_to_address)); + + return std::make_pair(source_address, data); +} + + +TEST(MaidManagerTest, BEH_CreateAccount) { + MaidManager maid_manager; + + passport::Anmaid anmaid; + passport::Maid maid(anmaid); + passport::PublicAnmaid public_anmaid(anmaid); + passport::PublicMaid public_maid(maid); + + // FakeRouting has ~75% success rate for creating an account + try { + maid_manager.HandleCreateAccount(public_maid, public_anmaid); + ASSERT_TRUE(maid_manager.HasAccount(public_maid.name())); + try { + // try creating an account for the same client + maid_manager.HandleCreateAccount(public_maid, public_anmaid); + } + catch (const maidsafe_error& error) { + ASSERT_EQ(make_error_code(VaultErrors::account_already_exists), error.code()); + } + } + catch (const maidsafe_error& error) { + ASSERT_EQ(make_error_code(VaultErrors::failed_to_handle_request), error.code()); + ASSERT_FALSE(maid_manager.HasAccount(public_maid.name())); + } +} + +TEST(MaidManagerTest, BEH_Put) { + using AccountName = MaidManager::AccountName; + + MaidManager maid_manager; + AccountName account_name(CreateAccount(maid_manager, std::numeric_limits().max())); + + // any reasonable number of puts should succeed + uint32_t puts((RandomUint32() % 1000) + 1); + for (size_t i = 0; i != puts; ++i) { + auto args(GetSourceAddressAndData(account_name, 10)); + auto result(maid_manager.HandlePut(args.first, args.second)); + + ASSERT_TRUE(result.valid()); + ASSERT_EQ(1, result.value().size()); + ASSERT_EQ(args.second.name().value.string(), result.value()[0].first.data.string()); + } +} + +TEST(MaidManagerTest, BEH_PutToLimit) { + using AccountName = MaidManager::AccountName; + + MaidManager maid_manager; + AccountName account_name(CreateAccount(maid_manager, 120)); + + for (size_t i = 0; i != 3; ++i) { + auto args(GetSourceAddressAndData(account_name, 10)); + auto result(maid_manager.HandlePut(args.first, args.second)); + + ASSERT_TRUE(result.valid()); + ASSERT_EQ(1, result.value().size()); + ASSERT_EQ(args.second.name().value.string(), result.value()[0].first.data.string()); + } +} + +TEST(MaidManagerTest, BEH_PutPastLimit) { + using AccountName = MaidManager::AccountName; + + MaidManager maid_manager; + AccountName account_name(CreateAccount(maid_manager, 120)); + + for (size_t i = 0; i != 3; ++i) { + auto args(GetSourceAddressAndData(account_name, 10)); + auto result(maid_manager.HandlePut(args.first, args.second)); + + ASSERT_TRUE(result.valid()); + ASSERT_EQ(1, result.value().size()); + ASSERT_EQ(args.second.name().value.string(), result.value()[0].first.data.string()); + } + + auto args(GetSourceAddressAndData(account_name, 10)); + auto result(maid_manager.HandlePut(args.first, args.second)); + + ASSERT_TRUE(!result.valid()); + ASSERT_EQ(make_error_code(CommonErrors::cannot_exceed_limit), result.error().code()); +} + +TEST(MaidManagerTest, BEH_PutWithoutAccount) { + using AccountName = MaidManager::AccountName; + + MaidManager maid_manager; + AccountName account_name(Identity(RandomAlphaNumericString(64))); + + auto args(GetSourceAddressAndData(account_name, 10)); + auto result(maid_manager.HandlePut(args.first, args.second)); + + ASSERT_TRUE(!result.valid()); + ASSERT_EQ(make_error_code(VaultErrors::no_such_account), result.error().code()); +} + +} // namespace test + +} // namespace vault + +} // namespace maidsafe From 5d67be1f3dc4cd3d69f145fb90357555a2a24f4d Mon Sep 17 00:00:00 2001 From: BSMaidSafe Date: Fri, 6 Mar 2015 10:50:56 +0000 Subject: [PATCH 2/5] Minor change. --- src/maidsafe/vault/maid_manager/maid_manager.h | 2 +- src/maidsafe/vault/tests/fake_routing.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/maidsafe/vault/maid_manager/maid_manager.h b/src/maidsafe/vault/maid_manager/maid_manager.h index 79a5d1d03..2121f31ae 100644 --- a/src/maidsafe/vault/maid_manager/maid_manager.h +++ b/src/maidsafe/vault/maid_manager/maid_manager.h @@ -121,7 +121,7 @@ routing::HandlePutPostReturn MaidManager::HandlePut( std::vector result; result.push_back(std::make_pair(routing::Destination(routing::Address(data.name())), - boost::optional())); + boost::none)); return routing::HandlePutPostReturn(result); } diff --git a/src/maidsafe/vault/tests/fake_routing.h b/src/maidsafe/vault/tests/fake_routing.h index cbca7b759..588f1f229 100644 --- a/src/maidsafe/vault/tests/fake_routing.h +++ b/src/maidsafe/vault/tests/fake_routing.h @@ -49,7 +49,7 @@ class FakeRouting { } template - PutReturn Put(Address to, DataType data, CompletionToken token) { + PutReturn Put(Address /*to*/, DataType /*data*/, CompletionToken token) { auto random(RandomInt32()); if (random >= 0 || std::abs(random) % 2 == 0 || std::abs(random) % 5 == 0) token(MakeError(CommonErrors::success)); From ab2c65a090a38433bac890b7806c3410b806197f Mon Sep 17 00:00:00 2001 From: BSMaidSafe Date: Tue, 10 Mar 2015 09:29:13 -0700 Subject: [PATCH 3/5] Test fix. --- src/maidsafe/vault/tests/fake_routing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/maidsafe/vault/tests/fake_routing.h b/src/maidsafe/vault/tests/fake_routing.h index 588f1f229..3991361f6 100644 --- a/src/maidsafe/vault/tests/fake_routing.h +++ b/src/maidsafe/vault/tests/fake_routing.h @@ -51,7 +51,7 @@ class FakeRouting { template PutReturn Put(Address /*to*/, DataType /*data*/, CompletionToken token) { auto random(RandomInt32()); - if (random >= 0 || std::abs(random) % 2 == 0 || std::abs(random) % 5 == 0) + if (random >= 0 || random % 2 == 0 || random % 5 == 0) token(MakeError(CommonErrors::success)); else token(MakeError(CommonErrors::defaulted)); From 0ed740d7c1956e2aa64132238f63c0d66f9f34c6 Mon Sep 17 00:00:00 2001 From: BSMaidSafe Date: Fri, 27 Mar 2015 13:40:25 +0000 Subject: [PATCH 4/5] Compile fixes. --- .../vault/tests/maid_manager_account_test.cc | 26 +++++++++++-------- src/maidsafe/vault/tests/maid_manager_test.cc | 20 +++++++------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/maidsafe/vault/tests/maid_manager_account_test.cc b/src/maidsafe/vault/tests/maid_manager_account_test.cc index 3225bf620..4fed7bcae 100644 --- a/src/maidsafe/vault/tests/maid_manager_account_test.cc +++ b/src/maidsafe/vault/tests/maid_manager_account_test.cc @@ -18,6 +18,7 @@ #include "maidsafe/common/test.h" #include "maidsafe/common/utils.h" +#include "maidsafe/common/data_types/immutable_data.h" #include "maidsafe/vault/maid_manager/account.h" @@ -30,7 +31,7 @@ namespace test { TEST(MaidManagerAccountTest, BEH_Construct) { { - MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericBytes(64))); uint64_t data_stored(1), space_available(1); MaidManagerAccount account(name, data_stored, space_available); @@ -42,7 +43,7 @@ TEST(MaidManagerAccountTest, BEH_Construct) { ASSERT_NO_THROW(MaidManagerAccount(std::move(account))); } { - MaidManagerAccount::AccountName name1(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name1(Identity(RandomAlphaNumericBytes(64))); uint64_t data1_stored(1), space1_available(1); MaidManagerAccount account1(name1, data1_stored, space1_available); @@ -50,7 +51,7 @@ TEST(MaidManagerAccountTest, BEH_Construct) { ASSERT_EQ(data1_stored, account1.data_stored()); ASSERT_EQ(space1_available, account1.space_available()); - MaidManagerAccount::AccountName name2(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name2(Identity(RandomAlphaNumericBytes(64))); uint64_t data2_stored(2), space2_available(2); MaidManagerAccount account2(name2, data2_stored, space2_available); @@ -69,7 +70,7 @@ TEST(MaidManagerAccountTest, BEH_Construct) { } TEST(MaidManagerAccountTest, BEH_SerialiseParse) { - MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericBytes(64))); uint64_t data_stored(0), space_available(100); MaidManagerAccount account1(name, data_stored, space_available); @@ -87,7 +88,7 @@ TEST(MaidManagerAccountTest, BEH_SerialiseParse) { } TEST(MaidManagerAccountTest, BEH_EqualityInequality) { - MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericBytes(64))); uint64_t data_stored(1), space_available(1); MaidManagerAccount account1(name, data_stored, space_available), account2(name, data_stored, space_available), @@ -100,8 +101,11 @@ TEST(MaidManagerAccountTest, BEH_EqualityInequality) { } TEST(MaidManagerAccountTest, BEH_Ordering) { - MaidManagerAccount::AccountName name1(Identity("A" + RandomAlphaNumericString(63))), - name2(Identity("B" + RandomAlphaNumericString(63))); + MaidManagerAccount::AccountName name1(Identity(RandomAlphaNumericBytes(64))), + name2(Identity(RandomAlphaNumericBytes(64))); + const_cast&>(name1.string())[0] = 'A'; + const_cast&>(name2.string())[0] = 'B'; + uint64_t data_stored(1), space_available(1); MaidManagerAccount account1(name1, data_stored, space_available), account2(name2, data_stored, space_available), @@ -119,7 +123,7 @@ TEST(MaidManagerAccountTest, BEH_Ordering) { } TEST(MaidManagerAccountTest, BEH_AllowPut) { - MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericBytes(64))); uint64_t data_stored(0), space_available(100); MaidManagerAccount account(name, data_stored, space_available); @@ -135,8 +139,8 @@ TEST(MaidManagerAccountTest, BEH_AllowPut) { ASSERT_EQ(MaidManagerAccount::Status::kOk, account.AllowPut(public_anpmid)); ASSERT_EQ(MaidManagerAccount::Status::kOk, account.AllowPut(public_pmid)); - NonEmptyString content1(RandomString(2)), content2(RandomString(23)), - content3(RandomString(26)); + NonEmptyString content1(RandomBytes(2)), content2(RandomBytes(23)), + content3(RandomBytes(26)); ImmutableData data1(content1), data2(content2), data3(content3); ASSERT_EQ(MaidManagerAccount::Status::kOk, account.AllowPut(data1)); @@ -145,7 +149,7 @@ TEST(MaidManagerAccountTest, BEH_AllowPut) { } TEST(MaidManagerAccountTest, BEH_PutDelete) { - MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericString(64))); + MaidManagerAccount::AccountName name(Identity(RandomAlphaNumericBytes(64))); uint64_t data_stored(0), space_available(100); const uint64_t kSize(100); MaidManagerAccount account(name, data_stored, space_available); diff --git a/src/maidsafe/vault/tests/maid_manager_test.cc b/src/maidsafe/vault/tests/maid_manager_test.cc index 439f638ef..74b757aa1 100644 --- a/src/maidsafe/vault/tests/maid_manager_test.cc +++ b/src/maidsafe/vault/tests/maid_manager_test.cc @@ -39,16 +39,16 @@ MaidManager::AccountName CreateAccount(MaidManager& ma for (;;) { try { maid_manager.HandleCreateAccount(public_maid, public_anmaid, space_offered); - EXPECT_TRUE(maid_manager.HasAccount(public_maid.name())); + EXPECT_TRUE(maid_manager.HasAccount(public_maid.Name())); break; } catch (const maidsafe_error& error) { EXPECT_EQ(make_error_code(VaultErrors::failed_to_handle_request), error.code()); - EXPECT_FALSE(maid_manager.HasAccount(public_maid.name())); + EXPECT_FALSE(maid_manager.HasAccount(public_maid.Name())); } } - return public_maid.name(); + return public_maid.Name(); } template @@ -56,7 +56,7 @@ std::pair GetSourceAddressAndData( const MaidManager::AccountName account_name, uint32_t data_size) { Data data(NonEmptyString(RandomAlphaNumericString(data_size))); - auto node_address(routing::NodeAddress(routing::Address(account_name.value))); + auto node_address(routing::NodeAddress(routing::Address(account_name.string()))); auto group_address = boost::optional(); auto reply_to_address = boost::optional(); auto source_address(routing::SourceAddress(node_address, group_address, reply_to_address)); @@ -76,7 +76,7 @@ TEST(MaidManagerTest, BEH_CreateAccount) { // FakeRouting has ~75% success rate for creating an account try { maid_manager.HandleCreateAccount(public_maid, public_anmaid); - ASSERT_TRUE(maid_manager.HasAccount(public_maid.name())); + ASSERT_TRUE(maid_manager.HasAccount(public_maid.Name())); try { // try creating an account for the same client maid_manager.HandleCreateAccount(public_maid, public_anmaid); @@ -87,7 +87,7 @@ TEST(MaidManagerTest, BEH_CreateAccount) { } catch (const maidsafe_error& error) { ASSERT_EQ(make_error_code(VaultErrors::failed_to_handle_request), error.code()); - ASSERT_FALSE(maid_manager.HasAccount(public_maid.name())); + ASSERT_FALSE(maid_manager.HasAccount(public_maid.Name())); } } @@ -105,7 +105,7 @@ TEST(MaidManagerTest, BEH_Put) { ASSERT_TRUE(result.valid()); ASSERT_EQ(1, result.value().size()); - ASSERT_EQ(args.second.name().value.string(), result.value()[0].first.data.string()); + ASSERT_EQ(args.second.Name().string(), result.value()[0].first.data.string()); } } @@ -121,7 +121,7 @@ TEST(MaidManagerTest, BEH_PutToLimit) { ASSERT_TRUE(result.valid()); ASSERT_EQ(1, result.value().size()); - ASSERT_EQ(args.second.name().value.string(), result.value()[0].first.data.string()); + ASSERT_EQ(args.second.Name().string(), result.value()[0].first.data.string()); } } @@ -137,7 +137,7 @@ TEST(MaidManagerTest, BEH_PutPastLimit) { ASSERT_TRUE(result.valid()); ASSERT_EQ(1, result.value().size()); - ASSERT_EQ(args.second.name().value.string(), result.value()[0].first.data.string()); + ASSERT_EQ(args.second.Name().string(), result.value()[0].first.data.string()); } auto args(GetSourceAddressAndData(account_name, 10)); @@ -151,7 +151,7 @@ TEST(MaidManagerTest, BEH_PutWithoutAccount) { using AccountName = MaidManager::AccountName; MaidManager maid_manager; - AccountName account_name(Identity(RandomAlphaNumericString(64))); + AccountName account_name(Identity(RandomAlphaNumericBytes(64))); auto args(GetSourceAddressAndData(account_name, 10)); auto result(maid_manager.HandlePut(args.first, args.second)); From 6d17087d10cd30464a194096988849ddc1a08c52 Mon Sep 17 00:00:00 2001 From: BSMaidSafe Date: Fri, 27 Mar 2015 09:04:25 -0700 Subject: [PATCH 5/5] Style fixes. --- src/maidsafe/vault/maid_manager/maid_manager.h | 1 + src/maidsafe/vault/tests/maid_manager_test.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/maidsafe/vault/maid_manager/maid_manager.h b/src/maidsafe/vault/maid_manager/maid_manager.h index 8bb3a63d8..4090b2b8d 100644 --- a/src/maidsafe/vault/maid_manager/maid_manager.h +++ b/src/maidsafe/vault/maid_manager/maid_manager.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "maidsafe/passport/types.h" #include "maidsafe/routing/types.h" diff --git a/src/maidsafe/vault/tests/maid_manager_test.cc b/src/maidsafe/vault/tests/maid_manager_test.cc index 74b757aa1..5048d818b 100644 --- a/src/maidsafe/vault/tests/maid_manager_test.cc +++ b/src/maidsafe/vault/tests/maid_manager_test.cc @@ -67,7 +67,7 @@ std::pair GetSourceAddressAndData( TEST(MaidManagerTest, BEH_CreateAccount) { MaidManager maid_manager; - + passport::Anmaid anmaid; passport::Maid maid(anmaid); passport::PublicAnmaid public_anmaid(anmaid); @@ -97,7 +97,7 @@ TEST(MaidManagerTest, BEH_Put) { MaidManager maid_manager; AccountName account_name(CreateAccount(maid_manager, std::numeric_limits().max())); - // any reasonable number of puts should succeed + // any reasonable number of puts should succeed uint32_t puts((RandomUint32() % 1000) + 1); for (size_t i = 0; i != puts; ++i) { auto args(GetSourceAddressAndData(account_name, 10));