Skip to content
Merged
Changes from all commits
Commits
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
126 changes: 63 additions & 63 deletions evm-tests/test/subnet.precompile.hyperparameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,28 @@ describe("Test the Subnet precompile contract", () => {
const totalNetworkAfterAdd = await api.query.SubtensorModule.TotalNetworks.getValue()
assert.ok(totalNetwork + 1 === totalNetworkAfterAdd)
});

it.only("Can register network with identity info and logo url", async () => {
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()

const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const tx = await contract["registerNetwork(bytes32,string,string,string,string,string,string,string,string)"](
hotkey2.publicKey,
"name",
"repo",
"contact",
"subnetUrl",
"discord",
"description",
"logoUrl",
"additional"
);
await tx.wait();
// it.only("Can register network with identity info and logo url", async () => {
// const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()

const totalNetworkAfterAdd = await api.query.SubtensorModule.TotalNetworks.getValue()
assert.ok(totalNetwork + 1 === totalNetworkAfterAdd)
});
// const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);

// const tx = await contract["registerNetwork(bytes32,string,string,string,string,string,string,string,string)"](
// hotkey2.publicKey,
// "name",
// "repo",
// "contact",
// "subnetUrl",
// "discord",
// "description",
// "logoUrl",
// "additional"
// );
// await tx.wait();

// const totalNetworkAfterAdd = await api.query.SubtensorModule.TotalNetworks.getValue()
// assert.ok(totalNetwork + 1 === totalNetworkAfterAdd)
// });

it("Can set servingRateLimit parameter", async () => {

Expand Down Expand Up @@ -330,26 +331,26 @@ describe("Test the Subnet precompile contract", () => {
assert.equal(valueFromContract, onchainValue);
})

it("Can set networkRegistrationAllowed parameter", async () => {
// it("Can set networkRegistrationAllowed parameter", async () => {

const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;
// const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
// const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
// const netuid = totalNetwork - 1;

const newValue = true;
const tx = await contract.setNetworkRegistrationAllowed(netuid, newValue);
await tx.wait();
// const newValue = true;
// const tx = await contract.setNetworkRegistrationAllowed(netuid, newValue);
// await tx.wait();

let onchainValue = await api.query.SubtensorModule.NetworkRegistrationAllowed.getValue(netuid)
// let onchainValue = await api.query.SubtensorModule.NetworkRegistrationAllowed.getValue(netuid)


let valueFromContract = Boolean(
await contract.getNetworkRegistrationAllowed(netuid)
);
// let valueFromContract = Boolean(
// await contract.getNetworkRegistrationAllowed(netuid)
// );

assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
})
// assert.equal(valueFromContract, newValue)
// assert.equal(valueFromContract, onchainValue);
// })

it("Can set networkPowRegistrationAllowed parameter", async () => {

Expand Down Expand Up @@ -492,52 +493,51 @@ describe("Test the Subnet precompile contract", () => {
assert.equal(valueFromContract, onchainValue);
})

it("Can set yuma3Enabled hyperparameter", async () =>
{
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;
it("Can set yuma3Enabled hyperparameter", async () => {
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;

const newValue = true;
const tx = await contract.setYuma3Enabled(netuid, newValue);
await tx.wait();
const newValue = true;
const tx = await contract.setYuma3Enabled(netuid, newValue);
await tx.wait();

let onchainValue = await api.query.SubtensorModule.Yuma3On.getValue(netuid)
let onchainValue = await api.query.SubtensorModule.Yuma3On.getValue(netuid)

let valueFromContract = Boolean(
await contract.getYuma3Enabled(netuid)
);
assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
let valueFromContract = Boolean(
await contract.getYuma3Enabled(netuid)
);
assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
})


it("Can set alphaValues parameter", async () => {
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;
// it("Can set alphaValues parameter", async () => {
// const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
// const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
// const netuid = totalNetwork - 1;

const newValue = [118, 52429];
const tx = await contract.setAlphaValues(netuid, newValue[0], newValue[1]);
await tx.wait();
// const newValue = [118, 52429];
// const tx = await contract.setAlphaValues(netuid, newValue[0], newValue[1]);
// await tx.wait();

let onchainValue = await api.query.SubtensorModule.AlphaValues.getValue(netuid)
// let onchainValue = await api.query.SubtensorModule.AlphaValues.getValue(netuid)

let value = await contract.getAlphaValues(netuid)
let valueFromContract = [Number(value[0]), Number(value[1])]
// let value = await contract.getAlphaValues(netuid)
// let valueFromContract = [Number(value[0]), Number(value[1])]

assert.equal(valueFromContract[0], newValue[0])
assert.equal(valueFromContract[1], newValue[1])
assert.equal(valueFromContract[0], onchainValue[0]);
assert.equal(valueFromContract[1], onchainValue[1]);
})
// assert.equal(valueFromContract[0], newValue[0])
// assert.equal(valueFromContract[1], newValue[1])
// assert.equal(valueFromContract[0], onchainValue[0]);
// assert.equal(valueFromContract[1], onchainValue[1]);
// })

it("Can set commitRevealWeightsInterval parameter", async () => {
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;

const newValue = 119;
const newValue = 99;
const tx = await contract.setCommitRevealWeightsInterval(netuid, newValue);
await tx.wait();

Expand Down
Loading