Socket
Socket
Sign inDemoInstall

4irelabs-blackchain-smart-contract

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

4irelabs-blackchain-smart-contract - npm Package Compare versions

Comparing version 0.0.50 to 0.0.51

278

dist/tests/createPlayer.test.js

@@ -43,6 +43,6 @@ "use strict";

// (
// await bc.getConsumables(
// new PublicKey("32bfaQGpZBM7P5AhS6TZne4PguKpSfMNTxBtxr7QRAh5")
// await bc.getWeapon(
// new PublicKey("DugfCChWT5R78ByB7duBuzpYSqRLCBeVvmKMheMLAVHz")
// )
// )?.[1].consumables
// )?.bonuses
// );

@@ -110,63 +110,79 @@ // console.log(

}));
test("Hire character", () => __awaiter(void 0, void 0, void 0, function* () {
//await bc.addRoom();
let tx = yield bc.hireCharacterWithoutSending("Dragon", types_1.ClassEnum.Templar);
expect(typeof tx).not.toBe("number");
yield bc.sendTransaction(tx[0]);
let character = yield bc.getCharacter(tx[1]);
expect(character).not.toBeNull();
character = character;
expect(character.name
.filter((ch) => ch !== 0)
.reduce((acc, ch) => acc + String.fromCharCode(ch), "")).toBe("Dragon");
expect(character.potions.map((x) => [
x.effectEnd.toString(),
(0, types_1.enumEq)(x.effect, types_1.PotionEnum.NoPotion),
])).toEqual([
["0", true],
["0", true],
["0", true],
["0", true],
["0", true],
]);
}));
test("Set character in tavern", () => __awaiter(void 0, void 0, void 0, function* () {
const player = (yield bc.getPlayerAccount());
let tx1 = yield bc.setCharacterWithoutSending(new web3_js_1.PublicKey(player.characters[0]));
expect(typeof tx1).not.toBe("number");
yield bc.sendTransaction(tx1);
let character = yield bc.getCharacter(player.characters[0]);
expect(character).not.toBeNull();
character = character;
expect((0, types_1.enumEq)(character.status, types_1.StatusEnum.Close)).toBe(true);
}));
test("Blind raid", () => __awaiter(void 0, void 0, void 0, function* () {
for (let i = 0; i < 1; i++) {
const player = (yield bc.getPlayerAccount());
const characterBefore = (yield bc.getCharacter(player.characters[0]));
let tx = yield bc.blindRaid(types_1.DifficultyEnum.Easy, player.characters[0]);
expect(typeof tx).not.toBe("number");
let sign = yield bc.sendTransaction(tx[0]);
expect(typeof sign).toBe("string");
sign = sign;
let battleLog = yield bc.getBattleLog(sign);
expect(typeof battleLog).not.toBe("number");
battleLog = battleLog;
console.log(battleLog);
let initDungeon = yield bc.getInitialDungeon(sign);
expect(typeof initDungeon).not.toBe("number");
initDungeon = initDungeon;
if (battleLog.complete != 100) {
let dungeon = yield bc.getDungeon(tx[1]);
expect(dungeon).not.toBeNull();
dungeon = dungeon;
expect(battleLog.receivedExp.toString()).toBe(initDungeon.exp.sub(dungeon.exp).toString());
}
else {
expect(battleLog.receivedExp.toString()).toBe(initDungeon.exp.subn(0).toString());
}
const characterAfter = (yield bc.getCharacter(player.characters[0]));
expect(battleLog.receivedExp.toString()).toBe(characterAfter.experience.sub(characterBefore.experience).toString());
}
}));
// test("Hire character", async () => {
// //await bc.addRoom();
// let tx = await bc.hireCharacterWithoutSending("Dragon", ClassEnum.Templar);
// expect(typeof tx).not.toBe("number");
// await bc.sendTransaction(tx[0] as Buffer);
// let character = await bc.getCharacter(tx[1] as PublicKey);
// expect(character).not.toBeNull();
// character = character as Character;
// expect(
// character.name
// .filter((ch) => ch !== 0)
// .reduce((acc, ch) => acc + String.fromCharCode(ch), "")
// ).toBe("Dragon");
// expect(
// character.potions.map((x) => [
// x.effectEnd.toString(),
// enumEq(x.effect, PotionEnum.NoPotion),
// ])
// ).toEqual([
// ["0", true],
// ["0", true],
// ["0", true],
// ["0", true],
// ["0", true],
// ]);
// });
// test("Set character in tavern", async () => {
// const player = (await bc.getPlayerAccount()) as PlayerAccount;
// let tx1 = await bc.setCharacterWithoutSending(
// new PublicKey(player.characters[0])
// );
// expect(typeof tx1).not.toBe("number");
// await bc.sendTransaction(tx1 as Buffer);
// let character = await bc.getCharacter(player.characters[0]);
// expect(character).not.toBeNull();
// character = character as Character;
// console.log(character);
// expect(enumEq(character.status, StatusEnum.Close)).toBe(true);
// });
// test("Blind raid", async () => {
// for (let i = 0; i < 1; i++) {
// const player = (await bc.getPlayerAccount()) as PlayerAccount;
// const characterBefore = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// let tx = await bc.blindRaid(DifficultyEnum.Easy, player.characters[0]);
// expect(typeof tx).not.toBe("number");
// let sign = await bc.sendTransaction(tx[0] as Buffer);
// expect(typeof sign).toBe("string");
// sign = sign as string;
// let battleLog = await bc.getBattleLog(sign);
// expect(typeof battleLog).not.toBe("number");
// battleLog = battleLog as BattleLog;
// console.log(battleLog);
// let initDungeon = await bc.getInitialDungeon(sign);
// expect(typeof initDungeon).not.toBe("number");
// initDungeon = initDungeon as Dungeon;
// if (battleLog.complete != 100) {
// let dungeon = await bc.getDungeon(tx[1]);
// expect(dungeon).not.toBeNull();
// dungeon = dungeon as Dungeon;
// expect(battleLog.receivedExp.toString()).toBe(
// initDungeon.exp.sub(dungeon.exp).toString()
// );
// } else {
// expect(battleLog.receivedExp.toString()).toBe(
// initDungeon.exp.subn(0).toString()
// );
// }
// const characterAfter = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// expect(battleLog.receivedExp.toString()).toBe(
// characterAfter.experience.sub(characterBefore.experience).toString()
// );
// }
// });
test("Use golds", () => __awaiter(void 0, void 0, void 0, function* () {

@@ -341,59 +357,79 @@ let consumablesBefore = (yield bc.getConsumables());

// });
test("Scouting & raid", () => __awaiter(void 0, void 0, void 0, function* () {
// for (let i = 0; i < 100; i++) {
const player = (yield bc.getPlayerAccount());
const characterBefore = (yield bc.getCharacter(player.characters[0]));
let tx1 = yield bc.scoutDungeonWithoutSending(types_1.DifficultyEnum.Hard, player.characters[0]);
expect(typeof tx1).not.toBe("number");
yield bc.sendTransaction(tx1[0]);
let initDungeon = yield bc.getDungeon(tx1[1]);
expect(initDungeon).not.toBeNull();
initDungeon = initDungeon;
let consumables = (yield bc.getConsumables())[1];
let potion = [];
let p = new anchor_1.BN();
for (let m of consumables.consumables) {
if (m.amount.gtn(0) &&
((0, types_1.enumEq)(m.typ, types_1.PotionEnum.LesserHealingPotion) ||
(0, types_1.enumEq)(m.typ, types_1.PotionEnum.CommonHealingPotion) ||
(0, types_1.enumEq)(m.typ, types_1.PotionEnum.FinestHealingPotion) ||
(0, types_1.enumEq)(m.typ, types_1.PotionEnum.GreatHealingPotion) ||
(0, types_1.enumEq)(m.typ, types_1.PotionEnum.MinorHealingPotion) ||
(0, types_1.enumEq)(m.typ, types_1.PotionEnum.SeekersStone) ||
(0, types_1.enumEq)(m.typ, types_1.PotionEnum.PhilosophianStoneReplica))) {
potion.push(m.typ);
p = m.amount;
}
}
let tx = yield bc.raid(tx1[1], player.characters[0], potion);
expect(typeof tx).not.toBe("number");
let sign = yield bc.sendTransaction(tx);
expect(typeof sign).toBe("string");
sign = sign;
let battleLog = yield bc.getBattleLog(sign);
expect(typeof battleLog).not.toBe("number");
battleLog = battleLog;
console.log(battleLog);
if (battleLog.complete != 100) {
let dungeon = yield bc.getDungeon(tx1[1]);
expect(dungeon).not.toBeNull();
dungeon = dungeon;
expect(battleLog.receivedExp.toString()).toBe(initDungeon.exp.sub(dungeon.exp).toString());
}
else {
expect(battleLog.receivedExp.toString()).toBe(initDungeon.exp.subn(0).toString());
}
const characterAfter = (yield bc.getCharacter(player.characters[0]));
expect(battleLog.receivedExp.toString()).toBe(characterAfter.experience.sub(characterBefore.experience).toString());
if (potion[0] !== undefined && battleLog.consumables.length == 0) {
let con = yield bc.getConsumables();
expect(con).not.toBeNull();
console.log(potion);
con = con;
for (let pot of potion) {
expect(con[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(pot))].amount.toString()).toBe(p.subn(1).toString());
}
}
//}
}));
// test("Scouting & raid", async () => {
// // for (let i = 0; i < 100; i++) {
// const player = (await bc.getPlayerAccount()) as PlayerAccount;
// const characterBefore = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// let tx1 = await bc.scoutDungeonWithoutSending(
// DifficultyEnum.Hard,
// player.characters[0]
// );
// expect(typeof tx1).not.toBe("number");
// await bc.sendTransaction(tx1[0] as Buffer);
// let initDungeon = await bc.getDungeon(tx1[1]);
// expect(initDungeon).not.toBeNull();
// initDungeon = initDungeon as Dungeon;
// let consumables = (
// (await bc.getConsumables()) as [PublicKey, Consumables]
// )[1];
// let potion: Potion[] = [];
// let p = new BN();
// for (let m of consumables.consumables) {
// if (
// m.amount.gtn(0) &&
// (enumEq(m.typ, PotionEnum.LesserHealingPotion) ||
// enumEq(m.typ, PotionEnum.CommonHealingPotion) ||
// enumEq(m.typ, PotionEnum.FinestHealingPotion) ||
// enumEq(m.typ, PotionEnum.GreatHealingPotion) ||
// enumEq(m.typ, PotionEnum.MinorHealingPotion) ||
// enumEq(m.typ, PotionEnum.SeekersStone) ||
// enumEq(m.typ, PotionEnum.PhilosophianStoneReplica))
// ) {
// potion.push(m.typ);
// p = m.amount;
// }
// }
// let tx = await bc.raid(tx1[1], player.characters[0], potion);
// expect(typeof tx).not.toBe("number");
// let sign = await bc.sendTransaction(tx as Buffer);
// expect(typeof sign).toBe("string");
// sign = sign as string;
// let battleLog = await bc.getBattleLog(sign);
// expect(typeof battleLog).not.toBe("number");
// battleLog = battleLog as BattleLog;
// console.log(battleLog);
// if (battleLog.complete != 100) {
// let dungeon = await bc.getDungeon(tx1[1]);
// expect(dungeon).not.toBeNull();
// dungeon = dungeon as Dungeon;
// expect(battleLog.receivedExp.toString()).toBe(
// initDungeon.exp.sub(dungeon.exp).toString()
// );
// } else {
// expect(battleLog.receivedExp.toString()).toBe(
// initDungeon.exp.subn(0).toString()
// );
// }
// const characterAfter = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// expect(battleLog.receivedExp.toString()).toBe(
// characterAfter.experience.sub(characterBefore.experience).toString()
// );
// if (potion[0] !== undefined && battleLog.consumables.length == 0) {
// let con = await bc.getConsumables();
// expect(con).not.toBeNull();
// console.log(potion);
// con = con as [PublicKey, Consumables];
// for (let pot of potion) {
// expect(
// con[1].consumables[
// consumablesTypeMap.get(JSON.stringify(pot))
// ].amount.toString()
// ).toBe(p.subn(1).toString());
// }
// }
// //}
// });
// test("Lock consumable", async () => {

@@ -400,0 +436,0 @@ // let consumables = (

{
"name": "4irelabs-blackchain-smart-contract",
"version": "0.0.50",
"version": "0.0.51",
"description": "Integration with Solana API",

@@ -5,0 +5,0 @@ "author": "",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc