Skip to content

Commit

Permalink
test(sdk): regenerate test vectors for Dash Platform v1.1 (#2062)
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek authored Aug 20, 2024
1 parent 9221397 commit 25edda3
Show file tree
Hide file tree
Showing 346 changed files with 93 additions and 84 deletions.
13 changes: 10 additions & 3 deletions packages/rs-sdk/tests/fetch/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct Config {
#[serde(default = "Config::default_document_id")]
pub existing_document_id: Identifier,
// Hex-encoded ProTxHash of the existing HP masternode
#[serde(default)]
#[serde(default = "Config::default_protxhash")]
pub masternode_owner_pro_reg_tx_hash: String,
}

Expand Down Expand Up @@ -223,8 +223,8 @@ impl Config {
// Next time we need to do it again and update this value :(. This is terrible.
// We should automate creation of identity for SDK tests when we have time.
Identifier::from_string(
"J2aTnrrc8eea3pQBY91QisM3QH5FM9JK11mQCVwxeMqj",
Encoding::Base58,
"a1534e47f60be71e823a9dbc9ceb6d3ea9f1ebde7a3773f03e49ef31c7d9c044",
Encoding::Hex,
)
.unwrap()
}
Expand All @@ -246,6 +246,13 @@ impl Config {
.join("vectors")
}

/// Existing masternode proTxHash. Must be updated every time test vectors are regenerated.
///
/// See documentation of [contested_resource_identity_votes_ok](super::contested_resource_identity_votes::contested_resource_identity_votes_ok).
fn default_protxhash() -> String {
String::from("d10bf435af7c75f5b07b09486af1212469d69fdc787589548e315776bc1052a1")
}

/// Return ProTxHash of an existing evo node, or None if not set
pub fn existing_protxhash(&self) -> Result<ProTxHash, String> {
hex::decode(&self.masternode_owner_pro_reg_tx_hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ async fn contested_resource_identity_votes_not_found() {
/// 0. Ensure you have at least 1 contested DPNS name in the system.
/// See [check_mn_voting_prerequisities](super::contested_resource::check_mn_voting_prerequisities) for more details.
///
/// 1. Grep log output of `yarn setup` to find `ProRegTx transaction ID` and `Owner Private Key`.
/// Use `ProRegTx transaction ID` to set `DASH_SDK_MASTERNODE_OWNER_PRO_REG_TX_HASH` in `packages/rs-sdk/tests/.env`.
/// 1. Grep log output of `yarn setup` (see logs/setup.log) to find `ProRegTx transaction ID` and `Owner Private Key`:
/// ```bash
/// egrep '(ProRegTx transaction ID|Owner Private Key)' logs/setup.log|head -n2
/// ```
/// Hardcode `ProRegTx transaction ID` in [Config::default_protxhash].
///
/// 2. Load masternode identity into [rs-platform-explorer](https://github.com/dashpay/rs-platform-explorer/):
///
Expand All @@ -78,7 +81,7 @@ async fn contested_resource_identity_votes_not_found() {
ignore = "requires manual DPNS names setup for masternode voting tests; see docs of contested_resource_identity_votes_ok()"
)]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn contested_resource_identity_votes_ok() {
pub(super) async fn contested_resource_identity_votes_ok() {
setup_logs();

let cfg = Config::new();
Expand Down
3 changes: 1 addition & 2 deletions packages/rs-sdk/tests/fetch/data_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ async fn test_data_contracts_2_nx() {
not(feature = "offline-testing"),
ignore = "This test requires special procedure to regenerate test vectors"
)]
#[ignore = "todo: Lukazs to re-enable"]
async fn test_data_contract_history_read() {
let cfg = Config::new();
let id = Identifier::from_string(
"df73e40f62ab71d99254037226093f38f683b28cf552f3459d2bdc28614191e0",
"20d16030541c0494e84064e2e72b5ec620546305849a2f9d5893a5e65072364d",
Encoding::Hex,
)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"$format_version":"0","id":"GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"4EfA9Jrvv3nnCFdSf7fad59851iiTRZ6Wcu6YVJ4iSeF","schemaDefs":null,"documentSchemas":{"domain":{"documentsMutable":false,"canBeDeleted":true,"transferable":1,"tradeMode":1,"type":"object","indices":[{"name":"parentNameAndLabel","properties":[{"normalizedParentDomainName":"asc"},{"normalizedLabel":"asc"}],"unique":true,"contested":{"fieldMatches":[{"field":"normalizedLabel","regexPattern":"^[a-zA-Z01-]{3,19}$"}],"resolution":0,"description":"If the normalized label part of this index is less than 20 characters (all alphabet a-z, A-Z, 0, 1, and -) then a masternode vote contest takes place to give out the name"}},{"name":"identityId","nullSearchable":false,"properties":[{"records.identity":"asc"}]}],"properties":{"label":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$","minLength":3,"maxLength":63,"position":0,"description":"Domain label. e.g. 'Bob'."},"normalizedLabel":{"type":"string","pattern":"^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-]{0,61}[a-hj-km-np-z0-9]$","maxLength":63,"position":1,"description":"Domain label converted to lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'b0b'","$comment":"Must be equal to the label in lowercase. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\"."},"parentDomainName":{"type":"string","pattern":"^$|^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$","minLength":0,"maxLength":63,"position":2,"description":"A full parent domain name. e.g. 'dash'."},"normalizedParentDomainName":{"type":"string","pattern":"^$|^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-\\.]{0,61}[a-hj-km-np-z0-9]$","minLength":0,"maxLength":63,"position":3,"description":"A parent domain name in lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'dash'","$comment":"Must either be equal to an existing domain or empty to create a top level domain. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\". Only the data contract owner can create top level domains."},"preorderSalt":{"type":"array","byteArray":true,"minItems":32,"maxItems":32,"position":4,"description":"Salt used in the preorder document"},"records":{"type":"object","properties":{"identity":{"type":"array","byteArray":true,"minItems":32,"maxItems":32,"position":1,"contentMediaType":"application/x.dash.dpp.identifier","description":"Identifier name record that refers to an Identity"}},"minProperties":1,"position":5,"additionalProperties":false},"subdomainRules":{"type":"object","properties":{"allowSubdomains":{"type":"boolean","description":"This option defines who can create subdomains: true - anyone; false - only the domain owner","$comment":"Only the domain owner is allowed to create subdomains for non top-level domains","position":0}},"position":6,"description":"Subdomain rules allow domain owners to define rules for subdomains","additionalProperties":false,"required":["allowSubdomains"]}},"required":["$createdAt","$updatedAt","$transferredAt","label","normalizedLabel","normalizedParentDomainName","preorderSalt","records","subdomainRules"],"additionalProperties":false,"$comment":"In order to register a domain you need to create a preorder. The preorder step is needed to prevent man-in-the-middle attacks. normalizedLabel + '.' + normalizedParentDomain must not be longer than 253 chars length as defined by RFC 1035. Domain documents are immutable: modification and deletion are restricted"},"preorder":{"documentsMutable":false,"canBeDeleted":true,"type":"object","indices":[{"name":"saltedHash","properties":[{"saltedDomainHash":"asc"}],"unique":true}],"properties":{"saltedDomainHash":{"type":"array","byteArray":true,"minItems":32,"maxItems":32,"position":0,"description":"Double sha-256 of the concatenation of a 32 byte random salt and a normalized domain name"}},"required":["saltedDomainHash"],"additionalProperties":false,"$comment":"Preorder documents are immutable: modification and deletion are restricted"}}}
{"$format_version":"0","id":"GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"domain":{"documentsMutable":false,"canBeDeleted":true,"transferable":1,"tradeMode":1,"type":"object","indices":[{"name":"parentNameAndLabel","properties":[{"normalizedParentDomainName":"asc"},{"normalizedLabel":"asc"}],"unique":true,"contested":{"fieldMatches":[{"field":"normalizedLabel","regexPattern":"^[a-zA-Z01-]{3,19}$"}],"resolution":0,"description":"If the normalized label part of this index is less than 20 characters (all alphabet a-z, A-Z, 0, 1, and -) then a masternode vote contest takes place to give out the name"}},{"name":"identityId","nullSearchable":false,"properties":[{"records.identity":"asc"}]}],"properties":{"label":{"type":"string","pattern":"^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$","minLength":3,"maxLength":63,"position":0,"description":"Domain label. e.g. 'Bob'."},"normalizedLabel":{"type":"string","pattern":"^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-]{0,61}[a-hj-km-np-z0-9]$","maxLength":63,"position":1,"description":"Domain label converted to lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'b0b'","$comment":"Must be equal to the label in lowercase. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\"."},"parentDomainName":{"type":"string","pattern":"^$|^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$","minLength":0,"maxLength":63,"position":2,"description":"A full parent domain name. e.g. 'dash'."},"normalizedParentDomainName":{"type":"string","pattern":"^$|^[a-hj-km-np-z0-9][a-hj-km-np-z0-9-\\.]{0,61}[a-hj-km-np-z0-9]$","minLength":0,"maxLength":63,"position":3,"description":"A parent domain name in lowercase for case-insensitive uniqueness validation. \"o\", \"i\" and \"l\" replaced with \"0\" and \"1\" to mitigate homograph attack. e.g. 'dash'","$comment":"Must either be equal to an existing domain or empty to create a top level domain. \"o\", \"i\" and \"l\" must be replaced with \"0\" and \"1\". Only the data contract owner can create top level domains."},"preorderSalt":{"type":"array","byteArray":true,"minItems":32,"maxItems":32,"position":4,"description":"Salt used in the preorder document"},"records":{"type":"object","properties":{"identity":{"type":"array","byteArray":true,"minItems":32,"maxItems":32,"position":1,"contentMediaType":"application/x.dash.dpp.identifier","description":"Identifier name record that refers to an Identity"}},"minProperties":1,"position":5,"additionalProperties":false},"subdomainRules":{"type":"object","properties":{"allowSubdomains":{"type":"boolean","description":"This option defines who can create subdomains: true - anyone; false - only the domain owner","$comment":"Only the domain owner is allowed to create subdomains for non top-level domains","position":0}},"position":6,"description":"Subdomain rules allow domain owners to define rules for subdomains","additionalProperties":false,"required":["allowSubdomains"]}},"required":["$createdAt","$updatedAt","$transferredAt","label","normalizedLabel","normalizedParentDomainName","preorderSalt","records","subdomainRules"],"transient":["preorderSalt"],"additionalProperties":false,"$comment":"In order to register a domain you need to create a preorder. The preorder step is needed to prevent man-in-the-middle attacks. normalizedLabel + '.' + normalizedParentDomain must not be longer than 253 chars length as defined by RFC 1035. Domain documents are immutable: modification and deletion are restricted"},"preorder":{"documentsMutable":false,"canBeDeleted":true,"type":"object","indices":[{"name":"saltedHash","properties":[{"saltedDomainHash":"asc"}],"unique":true}],"properties":{"saltedDomainHash":{"type":"array","byteArray":true,"minItems":32,"maxItems":32,"position":0,"description":"Double sha-256 of the concatenation of a 32 byte random salt and a normalized domain name"}},"required":["saltedDomainHash"],"additionalProperties":false,"$comment":"Preorder documents are immutable: modification and deletion are restricted"}}}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8fdaad8ac39e23c5b9e773184f5f54523f4bc7b1ed68a66b43c011ecfe8c6f3c38b5e8bae650b2b4434f4ff9f15e7417

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8fdaad8ac39e23c5b9e773184f5f54523f4bc7b1ed68a66b43c011ecfe8c6f3c38b5e8bae650b2b4434f4ff9f15e7417
Loading

0 comments on commit 25edda3

Please sign in to comment.