コード例 #1
0
        public async Task CanRestoreAFile()
        {
            var deleteAddress = await _network.GetSystemDeleteAdminAddress();

            if (deleteAddress is null)
            {
                _network.Output?.WriteLine("TEST SKIPPED: No access to System Delete Administrator Account.");
                return;
            }
            var restoreAddress = await _network.GetSystemUndeleteAdminAddress();

            if (restoreAddress is null)
            {
                _network.Output?.WriteLine("TEST SKIPPED: No access to System Undelete Administrator Account.");
                return;
            }

            await using var fxFile = await TestFile.CreateAsync(_network);

            await fxFile.Client.SystemDeleteFileAsync(fxFile, ctx => ctx.Payer = deleteAddress);

            var receipt = await fxFile.Client.SystemRestoreFileAsync(fxFile, ctx => ctx.Payer = restoreAddress);

            Assert.Equal(ResponseCode.Success, receipt.Status);
            Assert.Equal(restoreAddress, receipt.Id.Address);

            var info = await fxFile.Client.GetFileInfoAsync(fxFile.Record.File);

            Assert.NotNull(info);
            Assert.Equal(fxFile.Record.File, info.File);
            Assert.Equal(fxFile.CreateParams.Contents.Length, info.Size);
            Assert.Equal(fxFile.CreateParams.Expiration, info.Expiration);
            Assert.Equal(new Endorsement[] { fxFile.PublicKey }, info.Endorsements);
            Assert.False(info.Deleted);
        }
コード例 #2
0
        public async Task SystemRestoreContractIsBroken()
        {
            var systemAddress = await _network.GetSystemUndeleteAdminAddress();

            if (systemAddress is null)
            {
                _network.Output?.WriteLine("TEST SKIPPED: No access to System Delete Administrator Account.");
                return;
            }

            await using var fx = await GreetingContract.CreateAsync(_network);

            await fx.Client.DeleteContractAsync(fx, _network.Payer, fx.PrivateKey);

            var tex = await Assert.ThrowsAsync <TransactionException>(async() =>
            {
                await fx.Client.SystemRestoreContractAsync(fx.ContractRecord.Contract, ctx => ctx.Payer = systemAddress);
            });

            Assert.Equal(ResponseCode.InvalidFileId, tex.Status);
            Assert.StartsWith("Unable to restore contract, status: InvalidFileId", tex.Message);
        }