Пример #1
0
        static async Task BuyAsync(string token, string totalEos, string account, string permission = "active", int retryLeft = 3)
        {
            try
            {
                var result = await client.PushActionAsync(
                    "eosio.token", "transfer", account, permission, new object[] {
                    account, DexAccount,
                    totalEos,
                    token
                });

                if (!result.IsSucceeded)
                {
                    throw new Exception(result.Error);
                }
            }
            catch
            {
                if (retryLeft == 0)
                {
                    throw;
                }
                await BuyAsync(token, totalEos, account, permission, retryLeft : --retryLeft);
            }
        }
Пример #2
0
        public async Task CompileAndSetContractTests()
        {
            // Arrange
            await client.PushActionAsync("eosio.token", "create", "eosio.token", "active", new[] { "eosio.token", "1000000000.0000 KBY" });

            await client.PushActionAsync("eosio.token", "issue", "eosio.token", "active", new[] { "eosio.token", "1000000000.0000 KBY", "OneBox Init" });

            await client.CreateFolderAsync("/opt/eosio/contracts/pomelo");

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/pomelo.hpp", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/pomelo.hpp")));

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/pomelo.cpp", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/pomelo.cpp")));

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/CMakeLists.txt", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/CMakeLists.txt")));

            await client.CompileSmartContractAsync("/opt/eosio/contracts/pomelo");

            await client.GenerateKeyValuePair("/home/cleos-net/wallet/pomelo.txt");

            var keys = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/pomelo.txt");

            await client.ImportPrivateKeyToWalletAsync(keys.PrivateKey, "eosio.token");

            await client.CreateAccountAsync("eosio", "pomelo", keys.PublicKey, keys.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new[] { "eosio.token", "pomelo", "1000.0000 EOS", "" });

            var result = await client.SetContractAsync("/opt/eosio/contracts/pomelo", "pomelo", "pomelo");

            await client.PushActionAsync("pomelo", "setwhitelist", "pomelo", "active", new[] { "KBY", "eosio.token" });

            // Assert
            Assert.True(result.IsSucceeded);
        }
Пример #3
0
        static async Task Main(string[] args)
        {
            var client = new CleosClient("http://localhost:8888");
            await client.QuickLaunchOneBoxAsync();

            var keys = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/eosio.token.key.txt");

            await client.CreateAccountAsync("eosio", "yuko", keys.PublicKey, keys.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new object[] { "eosio.token", "yuko", "1000.0000 EOS", "" });

            var keys2 = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/eosio.token.key.txt");

            await client.ImportPrivateKeyToWalletAsync(keys2.PrivateKey, "eosio.token");

            await client.CreateAccountAsync("eosio", "counter", keys2.PublicKey, keys2.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new object[] { "eosio.token", "counter", "1000.0000 EOS", "" });

            await client.CreateFolderAsync("/opt/eosio/contracts/counter");

            await client.UploadFileAsync("/opt/eosio/contracts/counter/counter.cpp", File.ReadAllBytes("counter.cpp"));

            await client.UploadFileAsync("/opt/eosio/contracts/counter/CMakeLists.txt", File.ReadAllBytes("CMakeLists.txt"));

            await client.CompileSmartContractAsync("/opt/eosio/contracts/counter");

            await client.SetContractAsync("/opt/eosio/contracts/counter/build", "counter", "pomelo");

            await client.PushActionAsync("counter", "init", "counter", "active", new object[] { });

            await client.PushActionAsync("counter", "add", "counter", "active", new object[] { "counter" });
        }
Пример #4
0
        public async Task AddFavoriteTest(string token)
        {
            var jobPosition  = Convert.ToUInt64((await db.Constants.AsNoTracking().SingleAsync(x => x.Id == "action_pos")).Value);
            var addFavResult = await client.PushActionAsync(config.ContractAccount, "addfav", config.TestAccount, "active", new object[] { token });

            Assert.True(addFavResult.IsSucceeded);

            await Task.Delay(10000);

            // Assert timer hang
            Assert.True(Convert.ToUInt64((await db.Constants.AsNoTracking().SingleAsync(x => x.Id == "action_pos")).Value) > jobPosition);
            Assert.True(await db.Favorites.AnyAsync(x => x.Account == config.TestAccount && x.TokenId == token));
        }