Skip to content

Commit b72fee5

Browse files
authored
chore(transactions): add delegate resignation builder and tests (#207)
- add Delegate Resignation header include to `builder.hpp`. - add Delegate Resignation Builder file to `/builders/` dir. - add Delegate Resignation unit test. - add Delegate Resignation definition file to Unit Tests`CMakeLists.txt`. - update the CHANGELOG.
1 parent e995541 commit b72fee5

5 files changed

Lines changed: 80 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- added Delegate Resignation Builder and Tests ([#207])
12+
813
## [1.0.0] - 2020-02-13
914

1015
### Changed
@@ -129,3 +134,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
129134
[#190]: https://github.com/ArkEcosystem/cpp-crypto/pull/190
130135
[#198]: https://github.com/ArkEcosystem/cpp-crypto/pull/198
131136
[1.0.0]: https://github.com/ArkEcosystem/cpp-crypto/compare/0.7.0...1.0.0
137+
[#207]: https://github.com/ArkEcosystem/cpp-crypto/pull/207
138+
[unreleased]: https://github.com/ArkEcosystem/cpp-crypto/compare/1.0.0...develop

src/include/cpp-crypto/transactions/builders/builder.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// #include "transactions/builders/multi_signature.hpp"
1818
#include "transactions/builders/ipfs.hpp"
1919
#include "transactions/builders/multi_payment.hpp"
20+
#include "transactions/builders/delegate_resignation.hpp"
2021
#include "transactions/builders/htlc_lock.hpp"
2122
#include "transactions/builders/htlc_claim.hpp"
2223
#include "transactions/builders/htlc_refund.hpp"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* This file is part of Ark Cpp Crypto.
3+
*
4+
* (c) Ark Ecosystem <info@ark.io>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
**/
9+
10+
#ifndef ARK_TRANSACTIONS_BUILDERS_DELEGATE_RESIGNATION_HPP
11+
#define ARK_TRANSACTIONS_BUILDERS_DELEGATE_RESIGNATION_HPP
12+
13+
#include "transactions/builders/common.hpp"
14+
15+
namespace Ark {
16+
namespace Crypto {
17+
namespace transactions {
18+
namespace builder {
19+
20+
////////////////////////////////////////////////////////////////////////////////
21+
// Forward Declaration
22+
class DelegateResignation;
23+
24+
////////////////////////////////////////////////////////////////////////////////
25+
class DelegateResignation : public Common<DelegateResignation> {
26+
public:
27+
DelegateResignation() {
28+
this->transaction.data.type = DELEGATE_RESIGNATION_TYPE;
29+
}
30+
};
31+
32+
} // namespace builder
33+
} // namespace transactions
34+
} // namespace Crypto
35+
} // namespace Ark
36+
37+
#endif

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ set(TRANSACTIONS_BUILDERS_TEST_SOURCE
9999
${PROJECT_SOURCE_DIR}/transactions/builders/vote.cpp
100100
${PROJECT_SOURCE_DIR}/transactions/builders/ipfs.cpp
101101
${PROJECT_SOURCE_DIR}/transactions/builders/multi_payment.cpp
102+
${PROJECT_SOURCE_DIR}/transactions/builders/delegate_resignation.cpp
102103
${PROJECT_SOURCE_DIR}/transactions/builders/htlc_lock.cpp
103104
${PROJECT_SOURCE_DIR}/transactions/builders/htlc_claim.cpp
104105
${PROJECT_SOURCE_DIR}/transactions/builders/htlc_refund.cpp
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* This file is part of Ark Cpp Crypto.
3+
*
4+
* (c) Ark Ecosystem <info@ark.io>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
**/
9+
10+
#include "gtest/gtest.h"
11+
12+
#include "transactions/builders/delegate_resignation.hpp"
13+
14+
#include "interfaces/constants.h"
15+
16+
#include "fixtures/identity.hpp"
17+
#include "transactions/types/fixtures/delegate_registration.hpp"
18+
19+
#include "test_helpers.h"
20+
21+
using namespace Ark::Crypto;
22+
using namespace Ark::Crypto::transactions;
23+
24+
////////////////////////////////////////////////////////////////////////////////
25+
TEST(transactions_builders, delegate_resignation) {
26+
auto transaction = builder::DelegateResignation()
27+
.nonce(COMMON_NONCE)
28+
.senderPublicKey(fixtures::PublicKeyBytes.data())
29+
.fee(TYPE_2_FEE)
30+
.sign(fixtures::Passphrase)
31+
.build();
32+
33+
ASSERT_TRUE(transaction.verify());
34+
}

0 commit comments

Comments
 (0)