Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dynamic Address Book unit tests #2459

Merged
merged 19 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/node/NodeCreateTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setAccountId(accountId) {
this._requireNotFrozen();
this._accountId =
accountId instanceof AccountId
? accountId
Expand All @@ -207,7 +208,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get node account identifier.
* @returns {?AccountId}
*/
get getAccountId() {
get accountId() {
return this._accountId;
}

Expand All @@ -217,6 +218,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setDescription(description) {
this._requireNotFrozen();
if (description.length > DESCRIPTION_MAX_LENGTH) {
throw new Error(
`Description must be at most ${DESCRIPTION_MAX_LENGTH} characters.`,
Expand All @@ -231,7 +233,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get description of the node.
* @returns {?string}
*/
get getDescription() {
get description() {
return this._description;
}

Expand All @@ -241,6 +243,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setGossipEndpoints(gossipEndpoints) {
this._requireNotFrozen();
if (gossipEndpoints.length == 0) {
throw new Error("GossipEndpoints list must not be empty.");
}
Expand All @@ -260,7 +263,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get list of service endpoints for gossip.
* @returns {?Array<ServiceEndpoint>}
*/
get getGossipEndpoints() {
get gossipEndpoints() {
return this._gossipEndpoints;
}

Expand All @@ -282,6 +285,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setServiceEndpoints(serviceEndpoints) {
this._requireNotFrozen();
if (serviceEndpoints.length == 0) {
throw new Error("ServiceEndpoints list must not be empty.");
}
Expand All @@ -301,7 +305,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get list of service endpoints for gRPC calls.
* @returns {?Array<ServiceEndpoint>}
*/
get getServiceEndpoints() {
get serviceEndpoints() {
return this._serviceEndpoints;
}

Expand All @@ -323,6 +327,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setGossipCaCertificate(bytes) {
this._requireNotFrozen();
if (bytes.length == 0) {
throw new Error("GossipCaCertificate must not be empty.");
}
Expand All @@ -336,7 +341,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get certificate used to sign gossip events.
* @returns {?Uint8Array}
*/
get getGossipCaCertificate() {
get gossipCaCertificate() {
return this._gossipCaCertificate;
}

Expand All @@ -346,6 +351,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setCertificateHash(bytes) {
this._requireNotFrozen();
this._grpcCertificateHash = bytes;

return this;
Expand All @@ -355,7 +361,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get hash of the node gRPC TLS certificate.
* @returns {?Uint8Array}
*/
get getCertificateHash() {
get certificateHash() {
return this._grpcCertificateHash;
}

Expand All @@ -365,6 +371,7 @@ export default class NodeCreateTransaction extends Transaction {
* @returns {NodeCreateTransaction}
*/
setAdminKey(adminKey) {
this._requireNotFrozen();
this._adminKey = adminKey;

return this;
Expand All @@ -374,7 +381,7 @@ export default class NodeCreateTransaction extends Transaction {
* @description Get administrative key controlled by the node operator.
* @returns {?Key}
*/
get getAdminKey() {
get adminKey() {
return this._adminKey;
}

Expand Down
2 changes: 1 addition & 1 deletion src/node/NodeDeleteTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class NodeDeleteTransaction extends Transaction {
* @description Get consensus node identifier.
* @returns {?Long}
*/
get getNodeId() {
get nodeId() {
return this._nodeId;
}

Expand Down
27 changes: 19 additions & 8 deletions src/node/NodeUpdateTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setNodeId(nodeId) {
this._requireNotFrozen();
this._nodeId = nodeId;

return this;
Expand All @@ -220,7 +221,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get consensus node identifier in the network state.
* @returns {?Long}
*/
get getNodeId() {
get nodeId() {
return this._nodeId;
}

Expand All @@ -230,6 +231,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setAccountId(accountId) {
this._requireNotFrozen();
this._accountId =
accountId instanceof AccountId
? accountId
Expand All @@ -242,7 +244,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get desired new account identifier of the node.
* @returns {?AccountId}
*/
get getAccountId() {
get accountId() {
return this._accountId;
}

Expand All @@ -252,6 +254,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setDescription(description) {
this._requireNotFrozen();
if (description.length > DESCRIPTION_MAX_LENGTH) {
throw new Error(
`Description must be at most ${DESCRIPTION_MAX_LENGTH} characters.`,
Expand All @@ -274,7 +277,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get description of the node.
* @returns {?string}
*/
get getDescription() {
get description() {
return this._description;
}

Expand All @@ -284,6 +287,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setGossipEndpoints(gossipEndpoints) {
this._requireNotFrozen();
if (gossipEndpoints.length == 0) {
throw new Error("GossipEndpoints list must not be empty.");
}
Expand All @@ -303,7 +307,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get list of service endpoints for gossip.
* @returns {?Array<ServiceEndpoint>}
*/
get getGossipEndpoints() {
get gossipEndpoints() {
return this._gossipEndpoints;
}

Expand All @@ -313,6 +317,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
addGossipEndpoint(endpoint) {
this._requireNotFrozen();
if (this._gossipEndpoints != null) {
this._gossipEndpoints.push(endpoint);
}
Expand All @@ -325,6 +330,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setServiceEndpoints(serviceEndpoints) {
this._requireNotFrozen();
if (serviceEndpoints.length == 0) {
throw new Error("ServiceEndpoints list must not be empty.");
}
Expand All @@ -344,7 +350,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get list of service endpoints for gRPC calls.
* @returns {?Array<ServiceEndpoint>}
*/
get getServiceEndpoints() {
get serviceEndpoints() {
return this._serviceEndpoints;
}

Expand All @@ -354,6 +360,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
addServiceEndpoint(endpoint) {
this._requireNotFrozen();
if (this._serviceEndpoints != null) {
this._serviceEndpoints.push(endpoint);
}
Expand All @@ -366,6 +373,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setGossipCaCertificate(bytes) {
this._requireNotFrozen();
if (bytes.length == 0) {
throw new Error("GossipCaCertificate must not be empty.");
}
Expand All @@ -379,7 +387,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get certificate used to sign gossip events.
* @returns {?Uint8Array}
*/
get getGossipCaCertificate() {
get gossipCaCertificate() {
return this._gossipCaCertificate;
}

Expand All @@ -389,6 +397,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setCertificateHash(bytes) {
this._requireNotFrozen();
this._grpcCertificateHash = bytes;

return this;
Expand All @@ -398,7 +407,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get hash of the node gRPC TLS certificate.
* @returns {?Uint8Array}
*/
get getCertificateHash() {
get certificateHash() {
return this._grpcCertificateHash;
}

Expand All @@ -408,6 +417,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @returns {NodeUpdateTransaction}
*/
setAdminKey(adminKey) {
this._requireNotFrozen();
this._adminKey = adminKey;

return this;
Expand All @@ -417,7 +427,7 @@ export default class NodeUpdateTransaction extends Transaction {
* @description Get administrative key controlled by the node operator.
* @returns {?Key}
*/
get getAdminKey() {
get adminKey() {
return this._adminKey;
}

Expand Down Expand Up @@ -481,6 +491,7 @@ export default class NodeUpdateTransaction extends Transaction {
},
adminKey:
this._adminKey != null ? this._adminKey._toProtobufKey() : null,
nodeId: this._nodeId != null ? this._nodeId : null,
};
}

Expand Down
Loading