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

Adjust ingress expiry to not be more than 5 min after the consent message #705

Open
wants to merge 31 commits into
base: test-vectors
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8eb2d1f
Test Vectors
lmuntaner Sep 23, 2022
a92d7af
Test Vectors: Add list_neurons
lmuntaner Sep 23, 2022
95276bc
Stake Maturity Test Vectors
lmuntaner Oct 5, 2022
ea365cf
Set principal sender used by Zondax
lmuntaner Oct 28, 2022
ba03d44
Update List Neurons script (#243)
carlosala Dec 5, 2022
b180bd4
Test Vectors: Increase DD, start and stop dissolving
lmuntaner Dec 7, 2022
acdc5c6
Test Vectors: SNS add neuron permissions
lmuntaner Jan 11, 2023
9d64fd2
20230118: Setup
lmuntaner Jan 18, 2023
314215d
20230118: Issues #188 and #189
lmuntaner Jan 18, 2023
c0e3986
20230118: ICRC-1 Test Vectors
lmuntaner Jan 23, 2023
7f74a60
Test vectors 20231223
lmuntaner Jan 24, 2023
f3b1859
Test Vectors: 20230125 SNS Stake Maturity
lmuntaner Jan 25, 2023
754719c
Test Vectors: Fix 20230118 sns disburse vector
lmuntaner Jan 27, 2023
708434a
Test Vector: Fix icrc-1 import
lmuntaner Jan 30, 2023
b096baa
Test vectors: ICRC1 most with created_at set
lmuntaner Feb 1, 2023
dde6087
Test vectors: Disburse and Join CF for candid
lmuntaner Mar 21, 2023
cafbefa
Test Vectors: 2023-05-11
lmuntaner May 11, 2023
99d44aa
Test Vectors: 20230516
lmuntaner May 22, 2023
af9763c
Test Vectors: 20230524
lmuntaner May 24, 2023
6170bcc
Test Vectors: 20230524
lmuntaner May 24, 2023
ddf7ddd
Test Vectors: Change in stake neuron from 20230516
lmuntaner May 25, 2023
79dedb1
Test Vectors: Fix neuron stake vector 20230516
lmuntaner May 25, 2023
f8484d3
20230712: SNS Set Dissolve Timestamp
lmuntaner Jul 12, 2023
4f4ee61
Test vector: 20239121
lmuntaner Sep 21, 2023
7b4ad68
Test Vector: 20230927
lmuntaner Sep 27, 2023
2bff21a
Test Vectors: Stake neuron tx
lmuntaner Oct 3, 2023
f7a3e50
Test vector list_neurons new param
lmuntaner Jul 23, 2024
8581a16
Test vectors - fix 20240722 list_neurons
lmuntaner Jul 23, 2024
a055d71
Test vectors - 20240730 icrc-29
lmuntaner Jul 30, 2024
31aac8a
Fix expiry in test-vector (#698)
Aug 23, 2024
980970e
Adjust ingress expiry to not be more than 5 min after the consent mes…
Aug 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://github.com/Zondax/ledger-icp/issues/166
// We'll keep each script for reproducibility.
import { IDL } from "@dfinity/candid";
import { toLeaveCommunityFundRequest } from "../../packages/nns/src/canisters/governance/request.converters";
import { toLeaveCommunityFundRequest } from "@dfinity/nns/src/canisters/governance/request.converters";
import { ManageNeuronFn } from "./governance.idl";
import { createBlob, writeToJson } from "./utils";

Expand Down
42 changes: 42 additions & 0 deletions scripts/test-vectors/20220923-list-neurons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Date represents the date of the issue with the test vectors sent to Zondax:
// https://github.com/Zondax/ledger-icp/issues/166
// We'll keep each script for reproducibility.
import { IDL } from "@dfinity/candid";
import { NeuronId } from "@dfinity/nns/src";
import { fromListNeurons } from "@dfinity/nns/src/canisters/governance/request.converters";
import { ListNeuronsFn } from "./governance.idl";
import { createBlob, writeToJson } from "./utils";

const mockNeuronId = BigInt(15374508381553347371);
const mockNeuronId2 = BigInt(8836564053576662908);

const createListNeurons = (neuronIds?: NeuronId[]) => {
const rawRequestBody = fromListNeurons(neuronIds);

return {
blob_candid: createBlob({
arg: IDL.encode(ListNeuronsFn.argTypes, [rawRequestBody]),
methodName: "list_neurons",
}),
name: "List Neurons",
candid_request: rawRequestBody,
output: ["0 | Transaction type : List Own Neurons"],
};
};

const main = () => {
try {
const vectors = [createListNeurons()];

writeToJson({
data: vectors,
fileName: "test-vectors.json",
});
console.log("File created successfully");
} catch (error) {
console.log("There was an error");
console.log(error);
}
};

main();
114 changes: 114 additions & 0 deletions scripts/test-vectors/20220923-spawn-neuron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Date represents the date of the issue with the test vectors sent to Zondax:
// https://github.com/Zondax/ledger-icp/issues/166
// We'll keep each script for reproducibility.
import { IDL } from "@dfinity/candid";
import { NeuronId } from "@dfinity/nns/src";
import { toSpawnNeuronRequest } from "@dfinity/nns/src/canisters/governance/request.converters";
import { Principal } from "@dfinity/principal";
import { ManageNeuronFn } from "./governance.idl";
import { createBlob, splitPrincipal, writeToJson } from "./utils";

const mockNeuronId = BigInt(15374508381553347371);
const mockNeuronId2 = BigInt(8836564053576662908);
const mockPrincipal = Principal.fromText(
"xlmdg-vkosz-ceopx-7wtgu-g3xmd-koiyc-awqaq-7modz-zf6r6-364rh-oqe",
);

const createCandidSpawnNeuron = ({
neuronId,
percentageToSpawn,
newController,
nonce,
}: {
neuronId: NeuronId;
percentageToSpawn?: number;
newController?: Principal;
nonce?: bigint;
}) => {
const rawRequestBody = toSpawnNeuronRequest({
neuronId,
percentageToSpawn,
newController,
nonce,
});

const outputs = [
"Transaction type : Spawn Neuron",
`Neuron ID : ${neuronId}`,
];

if (percentageToSpawn !== undefined) {
outputs.push(`Percentage to spawn : ${percentageToSpawn}`);
}

const controllerMessages =
newController === undefined
? ["Controller : Self"]
: splitPrincipal(newController).map(
(data, i, elements) =>
`Controller [${i + 1}/${elements.length}] : ${data}`,
);

outputs.push(...controllerMessages);

if (nonce !== undefined) {
outputs.push(`Nonce : ${nonce}`);
}
return {
blob_candid: createBlob({
arg: IDL.encode(ManageNeuronFn.argTypes, [rawRequestBody]),
methodName: "manage_neuron",
}),
name: "Spawn Neuron",
candid_request: rawRequestBody,
output: outputs.map((data, index) => `${index + 1} | ${data}`),
};
};

const main = () => {
try {
const vectors = [
createCandidSpawnNeuron({
neuronId: mockNeuronId,
}),
createCandidSpawnNeuron({
neuronId: mockNeuronId2,
}),
createCandidSpawnNeuron({
neuronId: mockNeuronId2,
percentageToSpawn: 50,
}),
createCandidSpawnNeuron({
neuronId: mockNeuronId2,
newController: mockPrincipal,
}),
createCandidSpawnNeuron({
neuronId: mockNeuronId2,
percentageToSpawn: 50,
newController: mockPrincipal,
}),
createCandidSpawnNeuron({
neuronId: mockNeuronId,
percentageToSpawn: 50,
nonce: BigInt(12345),
}),
createCandidSpawnNeuron({
neuronId: mockNeuronId2,
percentageToSpawn: 30,
newController: mockPrincipal,
nonce: BigInt(12345),
}),
];

writeToJson({
data: vectors,
fileName: "test-vectors-20220817.json",
});
console.log("File created successfully");
} catch (error) {
console.log("There was an error");
console.log(error);
}
};

main();
71 changes: 71 additions & 0 deletions scripts/test-vectors/20221005-auto-stake-maturity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { IDL } from "@dfinity/candid";
import { NeuronId } from "@dfinity/nns/src";
import { toAutoStakeMaturityRequest } from "@dfinity/nns/src/canisters/governance/request.converters";
import { ManageNeuronFn } from "./governance.idl";
import { createBlob, writeToJson } from "./utils";

const mockNeuronId = BigInt(15374508381553347371);
const mockNeuronId2 = BigInt(8836564053576662908);

const createCandidAutoStakeMaturity = ({
neuronId,
autoStake: autoStake,
}: {
neuronId: NeuronId;
autoStake: boolean;
}) => {
const rawRequestBody = toAutoStakeMaturityRequest({
neuronId,
autoStake,
});

const outputs = [
"Transaction type : Set Auto Stake Maturity",
`Neuron ID : ${neuronId}`,
`Auto stake : ${autoStake}`,
];

return {
blob_candid: createBlob({
arg: IDL.encode(ManageNeuronFn.argTypes, [rawRequestBody]),
methodName: "manage_neuron",
}),
name: "Auto Stake Maturity",
candid_request: rawRequestBody,
output: outputs.map((data, index) => `${index + 1} | ${data}`),
};
};

const main = () => {
try {
const vectors = [
createCandidAutoStakeMaturity({
neuronId: mockNeuronId,
autoStake: true,
}),
createCandidAutoStakeMaturity({
neuronId: mockNeuronId2,
autoStake: true,
}),
createCandidAutoStakeMaturity({
neuronId: mockNeuronId2,
autoStake: false,
}),
createCandidAutoStakeMaturity({
neuronId: mockNeuronId,
autoStake: false,
}),
];

writeToJson({
data: vectors,
fileName: "auto-stake-maturity.json",
});
console.log("File created successfully");
} catch (error) {
console.log("There was an error");
console.log(error);
}
};

main();
77 changes: 77 additions & 0 deletions scripts/test-vectors/20221005-stake-maturity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { IDL } from "@dfinity/candid";
import { NeuronId } from "@dfinity/nns/src";
import { toStakeMaturityRequest } from "@dfinity/nns/src/canisters/governance/request.converters";
import { ManageNeuronFn } from "./governance.idl";
import { createBlob, writeToJson } from "./utils";

const mockNeuronId = BigInt(15374508381553347371);
const mockNeuronId2 = BigInt(8836564053576662908);

const createCandidStakeMaturity = ({
neuronId,
percentageToStake,
}: {
neuronId: NeuronId;
percentageToStake?: number;
}) => {
const rawRequestBody = toStakeMaturityRequest({
neuronId,
percentageToStake,
});

const outputs = [
"Transaction type : Stake Maturity Neuron",
`Neuron ID : ${neuronId}`,
`Percentage to stake : ${percentageToStake}`,
];

return {
blob_candid: createBlob({
arg: IDL.encode(ManageNeuronFn.argTypes, [rawRequestBody]),
methodName: "manage_neuron",
}),
name: "Stake Maturity",
candid_request: rawRequestBody,
output: outputs.map((data, index) => `${index + 1} | ${data}`),
};
};

const main = () => {
try {
const vectors = [
createCandidStakeMaturity({
neuronId: mockNeuronId,
}),
createCandidStakeMaturity({
neuronId: mockNeuronId2,
}),
createCandidStakeMaturity({
neuronId: mockNeuronId2,
percentageToStake: 50,
}),
createCandidStakeMaturity({
neuronId: mockNeuronId,
percentageToStake: 50,
}),
createCandidStakeMaturity({
neuronId: mockNeuronId,
percentageToStake: 15,
}),
createCandidStakeMaturity({
neuronId: mockNeuronId2,
percentageToStake: 30,
}),
];

writeToJson({
data: vectors,
fileName: "stake-maturity.json",
});
console.log("File created successfully");
} catch (error) {
console.log("There was an error");
console.log(error);
}
};

main();
49 changes: 49 additions & 0 deletions scripts/test-vectors/20221202-list-neurons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Date represents the date of the issue with the test vectors sent to Zondax:
// https://github.com/Zondax/ledger-icp/issues/166
// We'll keep each script for reproducibility.
import { IDL } from "@dfinity/candid";
import { NeuronId } from "@dfinity/nns/src";
import { fromListNeurons } from "@dfinity/nns/src/canisters/governance/request.converters";
import { ListNeuronsFn } from "./governance.idl";
import { createBlob, writeToJson } from "./utils";

const mockNeuronId = BigInt(15374508381553347371);
const mockNeuronId2 = BigInt(8836564053576662908);

const createListNeurons = (neuronIds?: NeuronId[]) => {
const rawRequestBody = fromListNeurons(neuronIds);

const test = {
blob_candid: createBlob({
arg: IDL.encode(ListNeuronsFn.argTypes, [rawRequestBody]),
methodName: "list_neurons",
}),
name: "List Neurons",
candid_request: rawRequestBody,
output: ["0 | Transaction type : List Own Neurons"],
};
neuronIds?.forEach((id, idx) => {
test.output.push(`${idx + 1} | Neuron ID ${idx + 1} : ${id}`);
});
return test;
};

const main = () => {
try {
const vectors = [
createListNeurons(),
createListNeurons([mockNeuronId, mockNeuronId2]),
];

writeToJson({
data: vectors,
fileName: "list-neurons.json",
});
console.log("File created successfully");
} catch (error) {
console.log("There was an error");
console.log(error);
}
};

main();
Loading
Loading