forked from stratisproject/StratisBitcoinFullNode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Renames GetFileDllHelper to SmartContractCompiler - Add SmartContractCompilationResult - Cleans up and unifies list of allowed assemblies in a Smart Contract - Update tests Related work items: stratisproject#701
- Loading branch information
Rowan de Haas
authored and
Rowan de Haas
committed
Apr 2, 2018
1 parent
8d757c0
commit 65a8624
Showing
23 changed files
with
550 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 79 additions & 50 deletions
129
src/Stratis.Bitcoin.Features.SmartContracts.Tests/DeterminismValidationTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Stratis.Bitcoin.Features.SmartContracts.Tests/SmartContractCompilerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Microsoft.CodeAnalysis; | ||
using Stratis.SmartContracts.Core; | ||
using Stratis.SmartContracts.Core.Compilation; | ||
using Xunit; | ||
|
||
namespace Stratis.Bitcoin.Features.SmartContracts.Tests | ||
{ | ||
public class SmartContractCompilerTests | ||
{ | ||
[Fact] | ||
public void SmartContract_Compiler_ReturnsFalse() | ||
{ | ||
SmartContractCompilationResult compilationResult = SmartContractCompiler.Compile("Uncompilable"); | ||
|
||
Assert.False(compilationResult.Success); | ||
Assert.NotEmpty(compilationResult.Diagnostics); | ||
Assert.Null(compilationResult.Compilation); | ||
} | ||
|
||
[Fact] | ||
public void SmartContract_Compiler_ReturnsTrue() | ||
{ | ||
SmartContractCompilationResult compilationResult = SmartContractCompiler.Compile("class C{static void M(){}}"); | ||
|
||
Assert.True(compilationResult.Success); | ||
Assert.Empty(compilationResult.Diagnostics); | ||
Assert.NotNull(compilationResult.Compilation); | ||
} | ||
|
||
[Fact] | ||
public void SmartContract_ReferenceResolver_HasCorrectAssemblies() | ||
{ | ||
List<Assembly> allowedAssemblies = ReferencedAssemblyResolver.AllowedAssemblies.ToList(); | ||
|
||
Assert.Equal(4, allowedAssemblies.Count); | ||
Assert.Contains(allowedAssemblies, a => a.GetName().Name == "System.Runtime"); | ||
Assert.Contains(allowedAssemblies, a => a.GetName().Name == "System.Private.CoreLib"); | ||
Assert.Contains(allowedAssemblies, a => a.GetName().Name == "Stratis.SmartContracts"); | ||
Assert.Contains(allowedAssemblies, a => a.GetName().Name == "System.Linq"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.