Skip to content

Commit

Permalink
Merge branch 'develop-merge-2.7' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Sep 17, 2020
2 parents 6a471c5 + 482b1f1 commit a027491
Show file tree
Hide file tree
Showing 65 changed files with 1,546 additions and 1,008 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.6.57] - 2020-09-17

### Fixed

- Only verify peer blocks < our height (c968e69d, @air1one)
- Stricter multipayment tx check (620027df, @air1one)
- Initialize maxPayload on connection create (3ac3eb17, @air1one)

## [2.6.54] - 2020-09-09

### Changed

- Verify peer claimed state (24a8b044, @air1one)

### Fixed

- Use head from utils (da13465e, @air1one)

## [2.6.52] - 2020-08-11

### Fixed

- Discard zero-padded R/S (#3950) (9f197fa1, @air1one)
- Check sig length value vs r/s length (#3950) (c2d3f2e5, @air1one)
- Find by address / public key before username (#3950) (ddd19cc2, @air1one)

## [2.6.49] - 2020-07-22

### Fixed
Expand Down Expand Up @@ -1007,6 +1033,7 @@ Closed security vulnerabilities:
- Initial Release

[unreleased]: https://github.com/ARKEcosystem/core/compare/master...develop
[2.6.25]: https://github.com/ARKEcosystem/core/compare/2.6.49...2.6.25
[2.6.49]: https://github.com/ARKEcosystem/core/compare/2.6.42...2.6.49
[2.6.42]: https://github.com/ARKEcosystem/core/compare/2.6.39...2.6.42
[2.6.39]: https://github.com/ARKEcosystem/core/compare/2.6.38...2.6.39
Expand Down Expand Up @@ -1576,6 +1603,7 @@ Closed security vulnerabilities:
[#3830]: https://github.com/ARKEcosystem/core/pull/3830
[#3904]: https://github.com/ARKEcosystem/core/pull/3904
[#3905]: https://github.com/ARKEcosystem/core/pull/3905
[#3950]: https://github.com/ARKEcosystem/core/pull/3950
[032caa1b990e91937e4bc1561bc1aeaeca9e37d]: https://github.com/ARKEcosystem/core/commit/032caa1b990e91937e4bc1561bc1aeaeca9e37d9
[1209a36366c8fd3ba31fab2463011b7ce1a7d84]: https://github.com/ARKEcosystem/core/commit/1209a36366c8fd3ba31fab2463011b7ce1a7d844
[34749bf84bcec3fecd0098c0d42f52deb1f6ba4]: https://github.com/ARKEcosystem/core/commit/34749bf84bcec3fecd0098c0d42f52deb1f6ba4a
Expand Down
102 changes: 76 additions & 26 deletions __tests__/functional/transaction-forging/entity-register.test.ts
Expand Up @@ -4,7 +4,7 @@ import { Contracts } from "@arkecosystem/core-kernel";
import { Enums } from "@arkecosystem/core-magistrate-crypto";
import secrets from "@arkecosystem/core-test-framework/src/internal/passphrases.json";
import { snoozeForBlock, TransactionFactory } from "@arkecosystem/core-test-framework/src/utils";
import { Identities } from "@arkecosystem/crypto";
import { Identities, Utils } from "@arkecosystem/crypto";
import { generateMnemonic } from "bip39";

import * as support from "./__support__";
Expand All @@ -16,40 +16,52 @@ afterAll(async () => await support.tearDown());
describe("Transaction Forging - Entity registration", () => {
describe("Signed with 1 Passphrase", () => {
it("should broadcast, accept and forge it [Signed with 1 Passphrase]", async () => {
// Registering a desktop wallet plugin
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
action: Enums.EntityAction.Register,
data: {
name: "my_plugin_for_desktop_wallet",
},
})
.withPassphrase(secrets[0])
.createOne();
// Registering all possible entity types/subTypes
const registrations = [];
let nonce = Utils.BigNumber.make(2);
for (const { type, subType, name } of [
{ type: Enums.EntityType.Business, subType: 0, name: "bzness" },
{ type: Enums.EntityType.Delegate, subType: 1, name: "genesis_1" },
{ type: Enums.EntityType.Product, subType: 6, name: "prduct" },
{ type: Enums.EntityType.Plugin, subType: 255, name: "plgincore" },
{ type: Enums.EntityType.Plugin, subType: 134, name: "plgindskt" },
{ type: 255, subType: 134, name: "type255shouldwork" },
{ type: 174, subType: 33, name: "type174shouldwork" },
]) {
registrations.push(
TransactionFactory.initialize(app)
.entity({ type, subType, action: Enums.EntityAction.Register, data: { name } })
.withPassphrase(secrets[0])
.withNonce(nonce)
.createOne(),
);
nonce = nonce.plus(1);
}

await expect(entityRegistration).not.toBeAccepted(); // aip36 not here yet
await expect(registrations[0]).not.toBeAccepted(); // aip36 not here yet
await snoozeForBlock(1);
await expect(entityRegistration.id).not.toBeForged();
for (const entityRegistration of registrations) {
await expect(entityRegistration.id).not.toBeForged();
}

for (let i = 0; i < 25; i++) {
for (let i = 0; i < 30; i++) {
await snoozeForBlock(1); // wait for aip36 to kick in, todo better way without waiting ? (snapshot ?)
}

await expect(entityRegistration).toBeAccepted();
await expect(registrations).toBeAllAccepted();
await snoozeForBlock(1);
await expect(entityRegistration.id).toBeForged();

await expect(entityRegistration).entityRegistered();
for (const entityRegistration of registrations) {
await expect(entityRegistration.id).toBeForged();
await expect(entityRegistration).entityRegistered();
}
});

it("should reject entity registration, because entity name contains unicode control characters [Signed with 1 Passphrase]", async () => {
// entity registration
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
subType: 1,
action: Enums.EntityAction.Register,
data: {
name: "\u0008name",
Expand All @@ -63,6 +75,44 @@ describe("Transaction Forging - Entity registration", () => {
await expect(entityRegistration.id).not.toBeForged();
await expect(entityRegistration).not.entityRegistered();
});

it("should reject entity registration, because entity type is > 255 [Signed with 1 Passphrase]", async () => {
// entity registration
const entityRegistration = TransactionFactory.initialize(app).entity({
type: 256,
subType: 1,
action: Enums.EntityAction.Register,
data: {
name: "name256",
},
})
.withPassphrase(secrets[0])
.createOne();

await expect(entityRegistration).toBeRejected();
await snoozeForBlock(1);
await expect(entityRegistration.id).not.toBeForged();
await expect(entityRegistration).not.entityRegistered();
});

it("should reject entity registration, because entity sub type is > 255 [Signed with 1 Passphrase]", async () => {
// entity registration
const entityRegistration = TransactionFactory.initialize(app).entity({
type: 1,
subType: 256,
action: Enums.EntityAction.Register,
data: {
name: "namesubtype256",
},
})
.withPassphrase(secrets[0])
.createOne();

await expect(entityRegistration).toBeRejected();
await snoozeForBlock(1);
await expect(entityRegistration.id).not.toBeForged();
await expect(entityRegistration).not.entityRegistered();
});
});

describe("Signed with 2 Passphrases", () => {
Expand Down Expand Up @@ -94,8 +144,8 @@ describe("Transaction Forging - Entity registration", () => {
// Registering entity
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Bridgechain,
subType: Enums.EntitySubType.None,
type: Enums.EntityType.Business,
subType: 0,
action: Enums.EntityAction.Register,
data: {
name: "my_bridgechain",
Expand Down Expand Up @@ -160,11 +210,11 @@ describe("Transaction Forging - Entity registration", () => {
// Registering entity
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Developer,
subType: Enums.EntitySubType.None,
type: Enums.EntityType.Module,
subType: 0,
action: Enums.EntityAction.Register,
data: {
name: "iam_a_developer",
name: "iam_a_module",
},
})
.withSenderPublicKey(multiSigPublicKey)
Expand Down
83 changes: 63 additions & 20 deletions __tests__/functional/transaction-forging/entity-resign.test.ts
Expand Up @@ -14,17 +14,20 @@ beforeAll(async () => (app = await support.setUp()));
afterAll(async () => await support.tearDown());

describe("Transaction Forging - Entity resign", () => {
const staticFeeResign = 500000000;
const subType = 5; // subType is valid between 0 and 255
const type = 177; // type is valid between 0 and 255
describe("Signed with 1 Passphrase", () => {
it("should broadcast, accept and forge it [Signed with 1 Passphrase]", async () => {
for (let i = 0; i < 25; i++) {
for (let i = 0; i < 30; i++) {
await snoozeForBlock(1); // wait for aip36 to kick in, todo better way without waiting ? (snapshot ?)
}

// Registering a desktop wallet plugin
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
type,
subType,
action: Enums.EntityAction.Register,
data: {
name: "my_plugin_for_desktop_wallet"
Expand All @@ -41,12 +44,13 @@ describe("Transaction Forging - Entity resign", () => {
// Resigning the entity
const entityResign = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
type,
subType,
action: Enums.EntityAction.Resign,
registrationId: entityRegistration.id,
data: {}
})
.withFee(staticFeeResign)
.withPassphrase(secrets[0])
.createOne();

Expand All @@ -56,12 +60,47 @@ describe("Transaction Forging - Entity resign", () => {
await expect(entityRegistration.id).entityResigned();
});

it("should reject entity resign, because of incorrect fee [Signed with 1 Passphrase]", async () => {
// entity registration
const entityRegistration = TransactionFactory.initialize(app).entity({
type: Enums.EntityType.Plugin,
subType,
action: Enums.EntityAction.Register,
data: {
name: "some_other_name",
},
})
.withPassphrase(secrets[0])
.createOne();

await expect(entityRegistration).toBeAccepted();
await snoozeForBlock(1);
await expect(entityRegistration.id).toBeForged();

// Trying to resign the desktop wallet plugin of secrets[0] wallet using secrets[1]
const entityResign = TransactionFactory.initialize(app).entity({
type: Enums.EntityType.Plugin,
subType,
action: Enums.EntityAction.Resign,
registrationId: entityRegistration.id,
data: {},
})
.withFee(5000000000) // this is an invalid fee - fee for register (50) instead of resign fee
.withPassphrase(secrets[1])
.createOne();

await expect(entityResign).toBeRejected();
await snoozeForBlock(1);
await expect(entityResign.id).not.toBeForged();
await expect(entityRegistration.id).not.entityResigned();
});

it("should reject entity resign, because associated register belongs to another wallet [Signed with 1 Passphrase]", async () => {
// entity registration
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
subType,
action: Enums.EntityAction.Register,
data: {
name: "another_name"
Expand All @@ -78,11 +117,12 @@ describe("Transaction Forging - Entity resign", () => {
const entityResign = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
subType,
action: Enums.EntityAction.Resign,
registrationId: entityRegistration.id,
data: {}
})
.withFee(staticFeeResign)
.withPassphrase(secrets[1])
.createOne();

Expand All @@ -97,7 +137,7 @@ describe("Transaction Forging - Entity resign", () => {
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginDesktop,
subType,
action: Enums.EntityAction.Register,
data: {
name: "again_another_name"
Expand All @@ -111,15 +151,16 @@ describe("Transaction Forging - Entity resign", () => {
await expect(entityRegistration.id).toBeForged();
await expect(entityRegistration).entityRegistered();

// Trying to resign the desktop wallet plugin using PluginCore subtype
// Trying to resign with a different subType
const entityResign = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Plugin,
subType: Enums.EntitySubType.PluginCore,
subType: subType + 11,
action: Enums.EntityAction.Resign,
registrationId: entityRegistration.id,
data: {}
})
.withFee(staticFeeResign)
.withPassphrase(secrets[0])
.createOne();

Expand Down Expand Up @@ -159,11 +200,11 @@ describe("Transaction Forging - Entity resign", () => {
// Registering entity
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Bridgechain,
subType: Enums.EntitySubType.None,
type: Enums.EntityType.Business,
subType,
action: Enums.EntityAction.Register,
data: {
name: "by_bridgechain"
name: "by_bizbiz"
}
})
.withPassphrase(passphrase)
Expand All @@ -177,12 +218,13 @@ describe("Transaction Forging - Entity resign", () => {
// Updating entity
const entityResign = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Bridgechain,
subType: Enums.EntitySubType.None,
type: Enums.EntityType.Business,
subType,
action: Enums.EntityAction.Resign,
registrationId: entityRegistration.id,
data: {}
})
.withFee(staticFeeResign)
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
.createOne();
Expand Down Expand Up @@ -241,11 +283,11 @@ describe("Transaction Forging - Entity resign", () => {
// Registering entity
const entityRegistration = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Developer,
subType: Enums.EntitySubType.None,
type: Enums.EntityType.Module,
subType,
action: Enums.EntityAction.Register,
data: {
name: "iam_a_developer"
name: "iam_a_module"
}
})
.withSenderPublicKey(multiSigPublicKey)
Expand All @@ -259,12 +301,13 @@ describe("Transaction Forging - Entity resign", () => {
// Updating entity
const entityResign = TransactionFactory.initialize(app)
.entity({
type: Enums.EntityType.Developer,
subType: Enums.EntitySubType.None,
type: Enums.EntityType.Module,
subType,
action: Enums.EntityAction.Resign,
registrationId: entityRegistration.id,
data: {}
})
.withFee(staticFeeResign)
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
.createOne();
Expand Down

0 comments on commit a027491

Please sign in to comment.