public async Task AssociatingWithDeletedAccountRaisesError() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await fxAccount.Client.DeleteAccountAsync(fxAccount, _network.Payer, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAccount.Client.AssociateTokenAsync(fxAsset.Record.Token, fxAccount.Record.Address, fxAccount.PrivateKey); }); Assert.Equal(ResponseCode.AccountDeleted, tex.Status); Assert.Equal(ResponseCode.AccountDeleted, tex.Receipt.Status); Assert.StartsWith("Unable to associate Token with Account, status: AccountDeleted", tex.Message); }
public void It_publishes_projects_with_filter_and_rid() { string project = "SimpleDependencies"; string targetFramework = "netcoreapp2.1"; var rid = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier(); TestAsset simpleDependenciesAsset = _testAssetsManager .CopyTestAsset(project) .WithSource() .WithProjectChanges(projectFile => { var ns = projectFile.Root.Name.Namespace; var targetFrameworkElement = projectFile.Root.Elements(ns + "PropertyGroup").Elements(ns + "TargetFramework").Single(); targetFrameworkElement.SetValue(targetFramework); }) .Restore(Log, "", $"/p:RuntimeIdentifier={rid}"); string filterProjDir = _testAssetsManager.GetAndValidateTestProjectDirectory("StoreManifests"); string manifestFile = Path.Combine(filterProjDir, "NewtonsoftFilterProfile.xml"); // According to https://github.com/dotnet/sdk/issues/1362 publish should throw an error // since this scenario is not supported. Running the published app doesn't work currently. // This test should be updated when that bug is fixed. PublishCommand publishCommand = new PublishCommand(Log, simpleDependenciesAsset.TestRoot); publishCommand .Execute($"/p:RuntimeIdentifier={rid}", $"/p:TargetManifestFiles={manifestFile}") .Should() .Pass(); DirectoryInfo publishDirectory = publishCommand.GetOutputDirectory(targetFramework, runtimeIdentifier: rid); publishDirectory.Should().HaveFiles(new[] { $"{project}.dll", $"{project}.pdb", $"{project}.deps.json", $"{project}.runtimeconfig.json", "System.Collections.NonGeneric.dll", $"{FileConstants.DynamicLibPrefix}coreclr{FileConstants.DynamicLibSuffix}" }); publishDirectory.Should().NotHaveFiles(new[] { "Newtonsoft.Json.dll", }); }
internal static void VerifyServiceWorkerFiles(TestAsset testAsset, string outputDirectory, string serviceWorkerPath, string serviceWorkerContent, string assetsManifestPath, string staticWebAssetsBasePath = "") { // Check the expected files are there var serviceWorkerResolvedPath = Path.Combine(testAsset.TestRoot, outputDirectory, staticWebAssetsBasePath, serviceWorkerPath); var assetsManifestResolvedPath = Path.Combine(testAsset.TestRoot, outputDirectory, staticWebAssetsBasePath, assetsManifestPath); // Check the service worker contains the expected content (which comes from the PublishedContent file) new FileInfo(serviceWorkerResolvedPath).Should().Contain(serviceWorkerContent); // Check the assets manifest version was added to the published service worker var assetsManifest = ReadServiceWorkerAssetsManifest(assetsManifestResolvedPath); new FileInfo(serviceWorkerResolvedPath).Should().Contain($"/* Manifest version: {assetsManifest.version} */"); // Check the assets manifest contains correct entries for all static content we're publishing var resolvedPublishDirectory = Path.Combine(testAsset.TestRoot, outputDirectory); var outputFiles = Directory.GetFiles(resolvedPublishDirectory, "*", new EnumerationOptions { RecurseSubdirectories = true }); var assetsManifestHashesByUrl = (IReadOnlyDictionary <string, string>)assetsManifest.assets.ToDictionary(x => x.url, x => x.hash); foreach (var filePath in outputFiles) { var relativePath = Path.GetRelativePath(resolvedPublishDirectory, filePath); // We don't list compressed files in the SWAM, as these are transparent to the client, // nor do we list the service worker itself or its assets manifest, as these don't need to be fetched in the same way if (IsCompressedFile(relativePath) || string.Equals(relativePath, Path.Combine(staticWebAssetsBasePath, serviceWorkerPath), StringComparison.Ordinal) || string.Equals(relativePath, Path.Combine(staticWebAssetsBasePath, assetsManifestPath), StringComparison.Ordinal)) { continue; } // Verify hash var fileUrl = relativePath.Replace('\\', '/'); var expectedHash = ParseWebFormattedHash(assetsManifestHashesByUrl[fileUrl]); assetsManifestHashesByUrl.Keys.Should().Contain(fileUrl); new FileInfo(filePath).Should().HashEquals(expectedHash); } }
//[Fact] public void It_publishes_projects_with_simple_dependencies() { TestAsset simpleDependenciesAsset = _testAssetsManager .CopyTestAsset("SimpleDependencies") .WithSource() .Restore(); PublishCommand publishCommand = new PublishCommand(Stage0MSBuild, simpleDependenciesAsset.TestRoot); publishCommand .Execute() .Should() .Pass(); DirectoryInfo publishDirectory = publishCommand.GetOutputDirectory(); publishDirectory.Should().OnlyHaveFiles(new[] { "SimpleDependencies.dll", "SimpleDependencies.pdb", "SimpleDependencies.deps.json", "SimpleDependencies.runtimeconfig.json", "Newtonsoft.Json.dll", "System.Runtime.Serialization.Primitives.dll", "System.Collections.NonGeneric.dll", }); string appPath = publishCommand.GetPublishedAppPath("SimpleDependencies"); Command runAppCommand = Command.Create( RepoInfo.DotNetHostPath, new[] { appPath, "one", "two" }); string expectedOutput = @"{ ""one"": ""one"", ""two"": ""two"" }"; runAppCommand .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining(expectedOutput); }
public void I_can_disable_1_x_implicit_msbuild_nuget_config(string frameworks, string projectPrefix, bool shouldExecutePass) { string testProjectName = $"{projectPrefix}1xDisabledFallback"; TestAsset testProjectTestAsset = CreateTestAsset(testProjectName, frameworks); var restoreCommand = testProjectTestAsset.GetRestoreCommand(Log, relativePath: testProjectName); var executeResult = restoreCommand.Execute($"/p:_NugetFallbackFolder={TestContext.Current.NuGetFallbackFolder}", "/p:DisableImplicit1xNuGetFallbackFolder=true"); if (shouldExecutePass) { executeResult.Should().Pass(); } else { executeResult.Should().Fail(); } }
public async Task CallingDeleteWithoutAdminKeyRaisesError() { await using var fx = await TestAsset.CreateAsync(_network); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fx.Client.DeleteTokenAsync(fx.Record.Token); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Delete Token, status: InvalidSignature", tex.Message); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.False(info.Deleted); }
private TestAsset SetupAndRestoreTestAsset([CallerMemberName] string callingMethod = "") { TestAsset testAsset = _testAssetsManager .CopyTestAsset("PortableToolWithP2P", callingMethod) .WithSource() .WithProjectChanges((projectPath, project) => { if (IsAppProject(projectPath)) { XNamespace ns = project.Root.Name.Namespace; XElement propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); propertyGroup.Add(new XElement(ns + "GeneratePackageOnBuild", "true")); } }); return(testAsset); }
public async Task CannotGrantAssetCoinsWhenGrantKYCTurnedOff() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null, fxAccount); await AssertHg.AssetStatusAsync(fxAsset, fxAccount, TokenKycStatus.NotApplicable); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount, fxAsset.GrantPrivateKey); }); Assert.Equal(ResponseCode.TokenHasNoKycKey, tex.Status); Assert.Equal(ResponseCode.TokenHasNoKycKey, tex.Receipt.Status); Assert.StartsWith("Unable to Grant Token, status: TokenHasNoKycKey", tex.Message); }
public void It_has_native_and_transitive_dependencies_dll(bool multiTarget) { TestAsset helloWorldAsset = _testAssetsManager .CopyTestAsset("PortableTool") .WithSource() .WithProjectChanges(project => { ChangeToPackageThatDependesOnOtherPackage(project); XNamespace ns = project.Root.Name.Namespace; XElement propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); if (multiTarget) { propertyGroup.Element(ns + "TargetFramework").Remove(); propertyGroup.Add(new XElement(ns + "TargetFrameworks", "netcoreapp1.1;netcoreapp2.0")); } }) .Restore(Log); var packCommand = new PackCommand(Log, helloWorldAsset.TestRoot); packCommand.Execute(); var nugetPackage = packCommand.GetNuGetPackage(); using (var nupkgReader = new PackageArchiveReader(nugetPackage)) { IEnumerable <NuGet.Frameworks.NuGetFramework> supportedFrameworks = nupkgReader.GetSupportedFrameworks(); supportedFrameworks.Should().NotBeEmpty(); var transitiveDependency = "runtimes/unix/lib/netstandard1.3/System.Data.SqlClient.dll"; var nativeDependency = "runtimes/win7-x86/native/sni.dll"; foreach (var dependency in new string[] { transitiveDependency, nativeDependency }) { foreach (NuGet.Frameworks.NuGetFramework framework in supportedFrameworks) { var allItems = nupkgReader.GetToolItems().SelectMany(i => i.Items).ToList(); allItems.Should().Contain($"tools/{framework.GetShortFolderName()}/any/{dependency}"); } } nupkgReader .GetPackageDependencies().First().Packages .Should().OnlyContain(p => p.Id == "Microsoft.NETCore.Platforms"); } }
public async Task CanDeleteAssetWithOneOfTwoMultSig() { var(pubAdminKey2, privateAdminKey2) = Generator.KeyPair(); await using var fx = await TestAsset.CreateAsync(_network, ctx => { ctx.Params.Administrator = new Endorsement(1, ctx.AdminPublicKey, pubAdminKey2); ctx.Params.Signatory = new Signatory(ctx.Params.Signatory, privateAdminKey2); }); var record = await fx.Client.DeleteTokenAsync(fx.Record.Token, fx.AdminPrivateKey); Assert.Equal(ResponseCode.Success, record.Status); var info = await fx.Client.GetTokenInfoAsync(fx.Record.Token); Assert.True(info.Deleted); }
public async Task GrantAssetCoinsRequiresGrantKeySignature() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.GrantTokenKycAsync(fxAsset.Record.Token, fxAccount); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Grant Token, status: InvalidSignature", tex.Message); }
public async Task CanConfiscateAssetFromTreasury() { await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); var circulation = (ulong)fxAsset.Metadata.Length; var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.ConfiscateAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAsset.ConfiscatePrivateKey); }); Assert.Equal(ResponseCode.CannotWipeTokenTreasuryAccount, tex.Status); Assert.Equal(ResponseCode.CannotWipeTokenTreasuryAccount, tex.Receipt.Status); Assert.StartsWith("Unable to Confiscate Token, status: CannotWipeTokenTreasuryAccount", tex.Message); Assert.Equal(circulation, (await fxAsset.Client.GetTokenInfoAsync(fxAsset)).Circulation); }
public async Task CanMintAssetsWithouExtraSignatory() { await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Metadata = null); Assert.NotNull(fxAsset.Record); Assert.NotNull(fxAsset.Record.Token); Assert.True(fxAsset.Record.Token.AccountNum > 0); Assert.Equal(ResponseCode.Success, fxAsset.Record.Status); var metadata = Enumerable.Range(1, Generator.Integer(2, 10)).Select(_ => Generator.SHA384Hash()).ToArray(); var receipt = await fxAsset.Client.MintAssetAsync(fxAsset.Record.Token, metadata, ctx => ctx.Signatory = new Signatory(_network.Signatory, fxAsset.SupplyPrivateKey)); Assert.Equal(ResponseCode.Success, receipt.Status); Assert.Equal(metadata.Length, receipt.SerialNumbers.Count); foreach (var serialNumber in receipt.SerialNumbers) { Assert.True(serialNumber > 0); } Assert.Equal((ulong)metadata.Length, receipt.Circulation); var info = await fxAsset.Client.GetTokenInfoAsync(fxAsset.Record.Token); Assert.Equal(fxAsset.Record.Token, info.Token); Assert.Equal(fxAsset.Params.Symbol, info.Symbol); Assert.Equal(fxAsset.TreasuryAccount.Record.Address, info.Treasury); Assert.Equal((ulong)metadata.Length, info.Circulation); Assert.Equal(0U, info.Decimals); Assert.Equal(fxAsset.Params.Ceiling, info.Ceiling); Assert.Equal(fxAsset.Params.Administrator, info.Administrator); Assert.Equal(fxAsset.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxAsset.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxAsset.Params.PauseEndorsement, info.PauseEndorsement); Assert.Equal(fxAsset.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxAsset.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenTradableStatus.Tradable, info.PauseStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.False(info.Deleted); Assert.Equal(fxAsset.Params.Memo, info.Memo); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ Assert.Equal((ulong)metadata.Length, await fxAsset.Client.GetAccountTokenBalanceAsync(fxAsset.TreasuryAccount, fxAsset)); }
public async Task MintAssetRequiresSignatureBySupplyKey() { await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Metadata = null); var metadata = Enumerable.Range(1, Generator.Integer(2, 10)).Select(_ => Generator.SHA384Hash()).ToArray(); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.MintAssetAsync(fxAsset.Record.Token, metadata); }); Assert.Equal(ResponseCode.InvalidSignature, tex.Status); Assert.Equal(ResponseCode.InvalidSignature, tex.Receipt.Status); Assert.StartsWith("Unable to Mint Token Coins, status: InvalidSignature", tex.Message); Assert.Equal(0UL, await fxAsset.Client.GetAccountTokenBalanceAsync(fxAsset.TreasuryAccount, fxAsset)); Assert.Equal(0UL, (await fxAsset.Client.GetTokenInfoAsync(fxAsset)).Circulation); }
public void It_creates_profiling_symbols() { if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { // profiling symbols are not supported on OSX return; } if (UsingFullFrameworkMSBuild) { // Disabled on full framework MSBuild until CI machines have VS with bundled .NET Core / .NET Standard versions // See https://github.com/dotnet/sdk/issues/1077 return; } TestAsset targetManifestsAsset = _testAssetsManager .CopyTestAsset("TargetManifests") .WithSource(); var outputFolder = Path.Combine(targetManifestsAsset.TestRoot, "o"); var workingDir = Path.Combine(targetManifestsAsset.TestRoot, "w"); new ComposeStore(Stage0MSBuild, targetManifestsAsset.TestRoot, "NewtonsoftFilterProfile.xml") .Execute( $"/p:RuntimeIdentifier={_runtimeRid}", "/p:TargetFramework=netcoreapp2.0", $"/p:ComposeDir={outputFolder}", $"/p:ComposeWorkingDir={workingDir}", "/p:DoNotDecorateComposeDir=true", "/p:PreserveComposeWorkingDir=true", "/p:CreateProfilingSymbols=true") .Should() .Pass(); var symbolFileExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "ni.pdb" : ".map"; var symbolsFolder = new DirectoryInfo(Path.Combine(outputFolder, "symbols")); var newtonsoftSymbolsFolder = symbolsFolder.Sub("newtonsoft.json").Sub("9.0.1").Sub("lib").Sub("netstandard1.0"); newtonsoftSymbolsFolder.Should().Exist(); var newtonsoftSymbolsFiles = newtonsoftSymbolsFolder.GetFiles().ToArray(); newtonsoftSymbolsFiles.Length.Should().Be(1); newtonsoftSymbolsFiles[0].Name.Should().StartWith("Newtonsoft.Json").And.EndWith(symbolFileExtension); }
public void GetByLogFile_Integration_ReturnsData() { string filePath = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName() + ".dbtest"); List <W3CEvent> logEvents = null; int logFileId = 0; using (StreamReader logStream = new StreamReader(TestAsset.ReadTextStream(TestAsset.LogFile))) { logEvents = W3CEnumerable.FromStream(logStream).ToList().GetRange(0, 10); } using (SQLiteDbContext dbContext = new SQLiteDbContext(filePath)) { dbContext.Initialise(); dbContext.BeginTransaction(); IRequestRepository requestRepo = new RequestRepository(dbContext); ICreateRequestBatchCommand createRequestBatchCommand = new CreateRequestBatchCommand(dbContext, new RequestValidator()); // create the project ProjectModel project = DataHelper.CreateProjectModel(); DataHelper.InsertProjectModel(dbContext, project); // create multiple log file records for (var i = 0; i < 3; i++) { LogFileModel logFile = DataHelper.CreateLogFileModel(project.Id); DataHelper.InsertLogFileModel(dbContext, logFile); createRequestBatchCommand.Execute(logFile.Id, logEvents); if (logFileId == 0) { logFileId = logFile.Id; } } IEnumerable <RequestModel> result = requestRepo.GetByLogFile(logFileId); Assert.IsNotNull(result); Assert.AreEqual(logEvents.Count, result.Count()); } }
public async Task CanNotScheduleConfiscateAssetCoins() { await using var fxPayer = await TestAccount.CreateAsync(_network); await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null, fxAccount); var initialCirculation = (ulong)fxAsset.Metadata.Length; var xferAmount = 2ul; var expectedTreasury = initialCirculation - xferAmount; var serialNumbersTransfered = Enumerable.Range(1, 2).Select(i => (long)i); var transferParams = new TransferParams { AssetTransfers = serialNumbersTransfered.Select(sn => new AssetTransfer(new Asset(fxAsset.Record.Token, sn), fxAsset.TreasuryAccount, fxAccount)), Signatory = fxAsset.TreasuryAccount }; await fxAsset.Client.TransferAsync(transferParams); Assert.Equal(xferAmount, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAccount, fxAsset)); Assert.Equal(expectedTreasury, await fxAccount.Client.GetAccountTokenBalanceAsync(fxAsset.TreasuryAccount, fxAsset)); Assert.Equal(initialCirculation, (await fxAsset.Client.GetTokenInfoAsync(fxAsset)).Circulation); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.ConfiscateAssetsAsync( fxAsset, new long[] { 1 }, fxAccount, new Signatory( fxAsset.ConfiscatePrivateKey, new PendingParams { PendingPayer = fxPayer }) ); }); Assert.Equal(ResponseCode.ScheduledTransactionNotInWhitelist, tex.Status); Assert.Equal(ResponseCode.ScheduledTransactionNotInWhitelist, tex.Receipt.Status); Assert.StartsWith("Unable to schedule transaction, status: ScheduledTransactionNotInWhitelist", tex.Message); }
public void It_publishes_projects_with_filter_and_rid() { string project = "SimpleDependencies"; var rid = RuntimeEnvironment.GetRuntimeIdentifier(); TestAsset simpleDependenciesAsset = _testAssetsManager .CopyTestAsset(project) .WithSource() .Restore("", $"/p:RuntimeIdentifier={rid}"); string filterProjDir = _testAssetsManager.GetAndValidateTestProjectDirectory("FilterProfiles"); string filterProjFile = Path.Combine(filterProjDir, "NewtonsoftFilterProfile.xml"); PublishCommand publishCommand = new PublishCommand(Stage0MSBuild, simpleDependenciesAsset.TestRoot); publishCommand .Execute($"/p:RuntimeIdentifier={rid}", $"/p:FilterProjectFiles={filterProjFile}") .Should() .Pass(); DirectoryInfo publishDirectory = publishCommand.GetOutputDirectory(runtimeIdentifier: rid); string libPrefix = ""; if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { libPrefix = "lib"; } publishDirectory.Should().HaveFiles(new[] { $"{project}.dll", $"{project}.pdb", $"{project}.deps.json", $"{project}.runtimeconfig.json", "System.Collections.NonGeneric.dll", $"{libPrefix}coreclr{Constants.DynamicLibSuffix}" }); publishDirectory.Should().NotHaveFiles(new[] { "Newtonsoft.Json.dll", "System.Runtime.Serialization.Primitives.dll" }); //TODO: Enable testing the run once dotnet host has the notion of looking up shared packages }
void VerifyAppBuilds(TestAsset testAsset) { var buildCommand = new BuildCommand(testAsset, "TestApp"); var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework); buildCommand .Execute() .Should() .Pass(); outputDirectory.Should().OnlyHaveFiles(new[] { "TestApp.dll", "TestApp.pdb", $"TestApp{EnvironmentInfo.ExecutableExtension}", "TestApp.deps.json", "TestApp.runtimeconfig.json", "TestLibrary.dll", "TestLibrary.pdb", }); new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll")) .Execute() .Should() .Pass() .And .HaveStdOutContaining("This string came from the test library!"); var appInfo = FileVersionInfo.GetVersionInfo(Path.Combine(outputDirectory.FullName, "TestApp.dll")); appInfo.CompanyName.Should().Be("Test Authors"); appInfo.FileVersion.Should().Be("1.2.3.0"); appInfo.FileDescription.Should().Be("Test AssemblyTitle"); appInfo.LegalCopyright.Should().Be("Copyright (c) Test Authors"); appInfo.ProductName.Should().Be("Test Product"); appInfo.ProductVersion.Should().Be("1.2.3-beta"); var libInfo = FileVersionInfo.GetVersionInfo(Path.Combine(outputDirectory.FullName, "TestLibrary.dll")); libInfo.CompanyName.Trim().Should().Be("TestLibrary"); libInfo.FileVersion.Should().Be("42.43.44.45"); libInfo.FileDescription.Should().Be("TestLibrary"); libInfo.LegalCopyright.Trim().Should().BeEmpty(); libInfo.ProductName.Should().Be("TestLibrary"); libInfo.ProductVersion.Should().Be("42.43.44.45-alpha"); }
public void TheSupportedTargetFrameworkListIsComposed() { var project = new TestProject { Name = "SupportedTargetFrameworkLists", TargetFrameworks = "netcoreapp3.0", IsSdkProject = true, }; TestAsset asset = _testAssetsManager.CreateTestProject(project); string testDirectory = Path.Combine(asset.TestRoot, project.Name); var supportedNetCoreAppTFs = GetItems( testDirectory, project.TargetFrameworks, "SupportedNETCoreAppTargetFramework"); supportedNetCoreAppTFs.Should().NotBeEmpty(); var supportedNetStandardTFs = GetItems( testDirectory, project.TargetFrameworks, "SupportedNETStandardTargetFramework"); supportedNetStandardTFs.Should().NotBeEmpty(); var supportedNetFrameworkTFs = GetItems( testDirectory, project.TargetFrameworks, "SupportedNETFrameworkTargetFramework"); supportedNetFrameworkTFs.Should().NotBeEmpty(); var supportedTFs = GetItems( testDirectory, project.TargetFrameworks, "SupportedTargetFramework"); supportedNetCoreAppTFs .Union(supportedNetStandardTFs) .Union(supportedNetFrameworkTFs) .Should() .Equal(supportedTFs); }
public async Task CanBurnSingleAsset() { await using var fxAsset = await TestAsset.CreateAsync(_network); Assert.NotNull(fxAsset.Record); Assert.NotNull(fxAsset.Record.Token); Assert.Equal(ResponseCode.Success, fxAsset.Record.Status); var expectedCirculation = (ulong)(fxAsset.Metadata.Length - 1); var serialNumbers = fxAsset.Metadata[0]; var asset = new Asset(fxAsset, 1); var receipt = await fxAsset.Client.BurnAssetAsync(asset, fxAsset.SupplyPrivateKey); Assert.Equal(ResponseCode.Success, receipt.Status); Assert.Equal(expectedCirculation, receipt.Circulation); var info = await fxAsset.Client.GetTokenInfoAsync(fxAsset); Assert.Equal(fxAsset.Record.Token, info.Token); Assert.Equal(fxAsset.Params.Symbol, info.Symbol); Assert.Equal(fxAsset.TreasuryAccount.Record.Address, info.Treasury); Assert.Equal(expectedCirculation, info.Circulation); Assert.Equal(0ul, info.Decimals); Assert.Equal(fxAsset.Params.Ceiling, info.Ceiling); Assert.Equal(fxAsset.Params.Administrator, info.Administrator); Assert.Equal(fxAsset.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxAsset.Params.PauseEndorsement, info.PauseEndorsement); Assert.Equal(fxAsset.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxAsset.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxAsset.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(fxAsset.Params.RoyaltiesEndorsement, info.RoyaltiesEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenTradableStatus.Tradable, info.PauseStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.Empty(info.Royalties); Assert.False(info.Deleted); Assert.Equal(fxAsset.Params.Memo, info.Memo); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ Assert.Equal(expectedCirculation, await fxAsset.Client.GetAccountTokenBalanceAsync(fxAsset.TreasuryAccount, fxAsset)); }
public async Task AnyoneWithAdminKeyCanDeleteAsset() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 120_00_000_000); await using var fxAsset = await TestAsset.CreateAsync(_network); var record = await fxAsset.Client.DeleteTokenAsync(fxAsset.Record.Token, fxAsset.AdminPrivateKey, ctx => { ctx.Payer = fxAccount.Record.Address; ctx.Signatory = fxAccount.PrivateKey; }); Assert.Equal(ResponseCode.Success, record.Status); var info = await fxAsset.Client.GetTokenInfoAsync(fxAsset.Record.Token); Assert.True(info.Deleted); }
private void RestoreAndBuildTestAssets() { TestAsset testAsset = _testAssetsManager .CopyTestAsset("AllResourcesInSatelliteDisableVersionGenerate") .WithSource(); var buildCommand = new BuildCommand(Log, testAsset.TestRoot); buildCommand .Execute() .Should() .Pass(); DirectoryInfo outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.1"); _mainAssemblyPath = Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.dll"); _satelliteAssemblyPath = Path.Combine(outputDirectory.FullName, "en", "AllResourcesInSatellite.resources.dll"); }
public async Task CanNotScheduleADeleteAsset() { await using var fxPayer = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 20_00_000_000); await using var fxAsset = await TestAsset.CreateAsync(_network); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.DeleteTokenAsync(fxAsset.Record.Token, new Signatory(fxAsset.AdminPrivateKey, new PendingParams { PendingPayer = fxPayer, })); }); Assert.Equal(ResponseCode.ScheduledTransactionNotInWhitelist, tex.Status); Assert.Equal(ResponseCode.ScheduledTransactionNotInWhitelist, tex.Receipt.Status); Assert.StartsWith("Unable to schedule transaction, status: ScheduledTransactionNotInWhitelist", tex.Message); }
public async Task NoAssetAutoAssociationResultsInError() { await using var fxAccount = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.AutoAssociationLimit = 0); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { await fxAsset.Client.TransferAssetAsync(new Asset(fxAsset, 1), fxAsset.TreasuryAccount, fxAccount, fxAsset.TreasuryAccount); }); Assert.Equal(ResponseCode.TokenNotAssociatedToAccount, tex.Status); Assert.StartsWith("Unable to execute transfers, status: TokenNotAssociatedToAccount", tex.Message); await AssertHg.AssetNotAssociatedAsync(fxAsset, fxAccount); }
private void RestoreAndBuildTestAssets([CallerMemberName] string callingMethod = "") { TestAsset testAsset = _testAssetsManager .CopyTestAsset("AllResourcesInSatelliteDisableVersionGenerate", callingMethod) .WithSource(); var buildCommand = new BuildCommand(testAsset); buildCommand .Execute() .Should() .Pass(); DirectoryInfo outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework); _mainAssemblyPath = Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.dll"); _satelliteAssemblyPath = Path.Combine(outputDirectory.FullName, "en", "AllResourcesInSatellite.resources.dll"); }
public void When_app_project_reference_a_library_it_flows_to_test_project() { TestAsset testAsset = _testAssetsManager .CopyTestAsset("PortableToolWithTestProject") .WithSource(); testAsset.Restore(Log, "App"); var appProjectDirectory = Path.Combine(testAsset.TestRoot, "Test"); var testCommand = new DotnetCommand(Log, "test", appProjectDirectory); testCommand .Execute() .Should() .Pass() .And .NotHaveStdOutContaining("Could not load file or assembly"); }
public void It_uses_outputs_to_bin_by_default(bool multiTarget) { TestAsset helloWorldAsset = SetUpHelloWorld(multiTarget); _testRoot = helloWorldAsset.TestRoot; var packCommand = new PackCommand(Log, helloWorldAsset.TestRoot); var outputDirectory = packCommand.GetOutputDirectory("netcoreapp2.1"); packCommand.Execute().Should().Pass(); string windowShimPath = Path.Combine(outputDirectory.FullName, $"shims/netcoreapp2.1/win-x64/{_customToolCommandName}.exe"); File.Exists(windowShimPath).Should().BeTrue($"Shim {windowShimPath} should exist"); string osxShimPath = Path.Combine(outputDirectory.FullName, $"shims/netcoreapp2.1/osx.10.12-x64/{_customToolCommandName}"); File.Exists(osxShimPath).Should().BeTrue($"Shim {osxShimPath} should exist"); }
public async Task AssociateWithAssociatedAssetRaisesError() { await using var fxAccount = await TestAccount.CreateAsync(_network); await using var fxAsset1 = await TestAsset.CreateAsync(_network, null, fxAccount); await using var fxAsset2 = await TestAsset.CreateAsync(_network); var tex = await Assert.ThrowsAsync <TransactionException>(async() => { var assets = new Address[] { fxAsset1.Record.Token, fxAsset2.Record.Token }; await fxAccount.Client.AssociateTokensAsync(assets, fxAccount.Record.Address, fxAccount.PrivateKey); }); Assert.Equal(ResponseCode.TokenAlreadyAssociatedToAccount, tex.Status); Assert.Equal(ResponseCode.TokenAlreadyAssociatedToAccount, tex.Receipt.Status); Assert.StartsWith("Unable to associate Token with Account, status: TokenAlreadyAssociatedToAccount", tex.Message); }
public void compose_multifile() { TestAsset simpleDependenciesAsset = _testAssetsManager .CopyTestAsset("ProfileLists") .WithSource(); ComposeCache cacheCommand = new ComposeCache(Stage0MSBuild, simpleDependenciesAsset.TestRoot, "NewtonsoftFilterProfile.xml"); var OutputFolder = Path.Combine(simpleDependenciesAsset.TestRoot, "o"); var WorkingDir = Path.Combine(simpleDependenciesAsset.TestRoot, "w"); var additonalproj1 = Path.Combine(simpleDependenciesAsset.TestRoot, "NewtonsoftMultipleVersions.xml"); var additonalproj2 = Path.Combine(simpleDependenciesAsset.TestRoot, "FluentAssertions.xml"); cacheCommand .Execute($"/p:RuntimeIdentifier={_runtimeRid}", $"/p:TargetFramework={_tfm}", $"/p:Additionalprojects={additonalproj1}%3b{additonalproj2}", $"/p:ComposeDir={OutputFolder}", $"/p:ComposeWorkingDir={WorkingDir}", "/p:DoNotDecorateComposeDir=true") .Should() .Pass(); DirectoryInfo cacheDirectory = new DirectoryInfo(OutputFolder); List <string> files_on_disk = new List <string> { "artifact.xml", @"newtonsoft.json/9.0.2-beta2/lib/netstandard1.1/Newtonsoft.Json.dll", @"newtonsoft.json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll", @"fluentassertions.json/4.12.0/lib/netstandard1.3/FluentAssertions.Json.dll" }; cacheDirectory.Should().HaveFiles(files_on_disk); var knownpackage = new HashSet <PackageIdentity>(); knownpackage.Add(new PackageIdentity("Newtonsoft.Json", NuGetVersion.Parse("9.0.1"))); knownpackage.Add(new PackageIdentity("Newtonsoft.Json", NuGetVersion.Parse("9.0.2-beta2"))); knownpackage.Add(new PackageIdentity("FluentAssertions.Json", NuGetVersion.Parse("4.12.0"))); var artifact = Path.Combine(OutputFolder, "artifact.xml"); var packagescomposed = ParseCacheArtifacts(artifact); packagescomposed.Count.Should().BeGreaterThan(0); foreach (var pkg in knownpackage) { packagescomposed.Should().Contain(elem => elem.Equals(pkg), "package {0}, version {1} was not expected to be cached", pkg.Id, pkg.Version); } }