This is my best solution so far ,but it doesn’t work correctly.
Account 1 (contract deployer ?) can basically delete everything
But account 2 (the user account) cannot delete himself.
Can someone help me ?
blz sir, muh famalie…
const People = artifacts.require("People");
const truffleAssert = require("truffle-assertions");
var account_one = "0x4F6256c7Ac1Aa5E1ED2c3C8044A81c04A0f95a3D";
var account_two = "0xfA6020641bE53eFB985D3cF90F620fA8d37491F4";
contract ("People", async function(accounts){
/*Create a Person Account1*/
it("should set senior status correctly", async function(){
let instance = await People.deployed();
await instance.createPerson("account1", 65, 190,
{from: account_one, value: web3.utils.toWei("1", "ether")});
let result = await instance.getPerson();
assert(result.senior === true, "Senior level not set");
/*Create a Person Account2*/
});
it("should set senior status correctly", async function(){
let instance = await People.deployed();
await instance.createPerson("account2", 65, 190,
{from: account_two, value: web3.utils.toWei("1", "ether")});
let result = await instance.getPerson();
assert(result.senior === true, "Senior level not set");
/*Delete Account Nr. 1 from Account 1 0x4F6256c7Ac1Aa5E1ED2c3C8044A81c04A0f95a3D*/
});
it("Delete Person", async function(){
let instance = await People.deployed();
await instance.deletePerson(account_one, {from: account_one});
let result = await instance.getPerson();
assert(result.age.toNumber() === 0, "No Data here");
/*Delete Account Nr. 2 from Account 2 0xfA6020641bE53eFB985D3cF90F620fA8d37491F4*/
});
it("Delete Person", async function(){
let instance = await People.deployed();
await instance.deletePerson(account_two, {from: account_two});
let result = await instance.getPerson();
assert(result.age.toNumber() === 0, "No Data here");
})
});