public void TestBuyDuringSaleWhitelistedSinglePurchase() { var env = new TestEnviroment(1); var n = 0; var original_balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); var is_whitelisted = env.IsWhitelisted(env.whitelisted_buyerKeys[n].address.AddressToScriptHash()); Assert.IsTrue(is_whitelisted); env.api.Chain.Time = PhantasmaContract.ico_start_time + 1; var neo_amount = 5; env.api.SendAsset(env.owner_keys, env.whitelisted_buyerKeys[n].address, "NEO", neo_amount); var tx = TokenSale.MintTokens(env.token, env.whitelisted_buyerKeys[n], "NEO", neo_amount); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); //Assert.IsNotNull(notifications); //Assert.IsTrue(notifications.Count == 1); var new_balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); var expected_balance = original_balance + neo_amount * (int)(PhantasmaContract.token_swap_rate / PhantasmaContract.soul_decimals); Assert.IsTrue(new_balance == expected_balance); }
public void FailBuyOutsideSalePeriodEvenIfWhitelisted() { var env = new TestEnviroment(1); var n = 0; var original_balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); var is_whitelisted = env.IsWhitelisted(env.whitelisted_buyerKeys[n].address.AddressToScriptHash()); Assert.IsTrue(is_whitelisted); var neo_amount = 5; env.api.SendAsset(env.owner_keys, env.whitelisted_buyerKeys[n].address, "NEO", neo_amount); env.api.Chain.Time = PhantasmaContract.ico_start_time - 100; var tx = TokenSale.MintTokens(env.token, env.whitelisted_buyerKeys[n], "NEO", neo_amount); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); Assert.IsNull(notifications); var new_balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); Assert.IsTrue(new_balance == original_balance); }
public void FailBuyOutsideSalePeriod() { var env = new TestEnviroment(0); var random_buyerKeys = KeyPair.GenerateAddress(); var original_balance = env.token.BalanceOf(random_buyerKeys); var neo_amount = 5; env.api.SendAsset(env.owner_keys, random_buyerKeys.address, "NEO", neo_amount); env.api.Chain.Time = PhantasmaContract.ico_start_time - 100; var tx = TokenSale.MintTokens(env.token, random_buyerKeys, "NEO", neo_amount); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); //Assert.IsNull(notifications); var new_balance = env.token.BalanceOf(random_buyerKeys); Assert.IsTrue(new_balance == original_balance); }
public void TestTokenDeploy() { var env = new TestEnviroment(0); env.api.Chain.DettachDebugger(); Assert.IsTrue(env.token.TotalSupply == 0); var tx = TokenSale.Deploy(env.token, env.team_keys); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); Assert.IsNotNull(notifications); Assert.IsTrue(notifications.Count == 2); var account = env.api.Chain.GetAccount(contract_script_hash); Assert.IsTrue(account.storage.entries.Count > 0); var presale_balance = env.token.BalanceOf(PhantasmaContract.Presale_Address); Assert.IsTrue(presale_balance == (PhantasmaContract.presale_supply / PhantasmaContract.soul_decimals)); var plaform_balance = env.token.BalanceOf(PhantasmaContract.Platform_Address); Assert.IsTrue(plaform_balance == (PhantasmaContract.platform_supply / PhantasmaContract.soul_decimals)); Assert.IsTrue(env.token.TotalSupply == (PhantasmaContract.initialSupply / PhantasmaContract.soul_decimals)); }
public void TestNEP5() { var env = new TestEnviroment(0); Assert.IsTrue(env.token.Name == "Phantasma"); Assert.IsTrue(env.token.Symbol == "SOUL"); Assert.IsTrue(env.token.Decimals == 8); }
public void WithdrawNeoAfterSale() { var env = new TestEnviroment(20); env.api.Chain.Time = PhantasmaContract.ico_start_time + 1; var total_amount = 0; for (int n = 0; n < env.whitelisted_buyerKeys.Length; n++) { var is_whitelisted = env.IsWhitelisted(env.whitelisted_buyerKeys[n].address.AddressToScriptHash()); Assert.IsTrue(is_whitelisted); var neo_amount = 1 + n % 10; total_amount += neo_amount; env.api.SendAsset(env.owner_keys, env.whitelisted_buyerKeys[n].address, "NEO", neo_amount); Assert.IsTrue(env.api.Chain.Time > PhantasmaContract.ico_start_time); Assert.IsTrue(env.api.Chain.Time < PhantasmaContract.ico_war_time); var tx = TokenSale.MintTokens(env.token, env.whitelisted_buyerKeys[n], "NEO", neo_amount); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); //Assert.IsNotNull(notifications); //Assert.IsTrue(notifications.Count == 1); var balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); var expected_balance = neo_amount * (int)(PhantasmaContract.token_swap_rate / PhantasmaContract.soul_decimals); Assert.IsTrue(balance == expected_balance); } var balances = env.api.GetAssetBalancesOf(contract_script_hash); Assert.IsTrue(balances.ContainsKey("NEO")); Assert.IsTrue(balances["NEO"] == total_amount); }
public void TestBuyDuringSaleWhitelistedMultiplePurchases() { var env = new TestEnviroment(1); var n = 0; var original_balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); var is_whitelisted = env.IsWhitelisted(env.whitelisted_buyerKeys[n].address.AddressToScriptHash()); Assert.IsTrue(is_whitelisted); env.api.Chain.Time = PhantasmaContract.ico_start_time + 100; // total should be 10 or less var purchases = new int[] { 3, 2, 4, 1 }; var neo_amount = purchases.Sum(); env.api.SendAsset(env.owner_keys, env.whitelisted_buyerKeys[n].address, "NEO", neo_amount); for (int i = 0; i < purchases.Length; i++) { var tx = TokenSale.MintTokens(env.token, env.whitelisted_buyerKeys[n], "NEO", purchases[i]); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); //Assert.IsNotNull(notifications); //Assert.IsTrue(notifications.Count == 1); // advance time env.api.Chain.Time += (uint)(1000 * purchases[i] * 20); } var new_balance = env.token.BalanceOf(env.whitelisted_buyerKeys[n]); var expected_balance = original_balance + neo_amount * (int)(PhantasmaContract.token_swap_rate / PhantasmaContract.soul_decimals); Assert.IsTrue(new_balance == expected_balance); }
public void FailBuyDuringSaleNoWhitelist() { var env = new TestEnviroment(0); var neo_amount = 5; var random_buyerKeys = KeyPair.GenerateAddress(); env.api.SendAsset(env.owner_keys, random_buyerKeys.address, "NEO", neo_amount); env.api.Chain.Time = PhantasmaContract.ico_start_time + 1; var tx = TokenSale.MintTokens(env.token, random_buyerKeys, "NEO", neo_amount); Assert.IsNotNull(tx); var notifications = env.api.Chain.GetNotifications(tx); Assert.IsNull(notifications); var balance = env.token.BalanceOf(random_buyerKeys); Assert.IsTrue(balance == 0); }