diff --git a/src/Stratis.SmartContracts.CLR.Tests/Loader/ContractAssemblyTests.cs b/src/Stratis.SmartContracts.CLR.Tests/Loader/ContractAssemblyTests.cs index 500aac96d6..5082ed2092 100644 --- a/src/Stratis.SmartContracts.CLR.Tests/Loader/ContractAssemblyTests.cs +++ b/src/Stratis.SmartContracts.CLR.Tests/Loader/ContractAssemblyTests.cs @@ -128,5 +128,34 @@ public Test(ISmartContractState state) Assert.NotNull(type); Assert.Equal("Test", type.Name); } + + [Fact] + public void GetDeployedType_TwoLevelsOfInheritance_CorrectType() + { + var code = @" +using Stratis.SmartContracts; + +public class BaseType : SmartContract +{ + public BaseType(ISmartContractState state) : base(state) {} +} + +[Deploy] +public class InheritedType : BaseType +{ + public InheritedType(ISmartContractState state) : base(state) {} +} +"; + var compilation = ContractCompiler.Compile(code); + + var assemblyLoadResult = this.loader.Load((ContractByteCode)compilation.Compilation); + + var contractAssembly = assemblyLoadResult.Value; + + var type = contractAssembly.DeployedType; + + Assert.NotNull(type); + Assert.Equal("InheritedType", type.Name); + } } } diff --git a/src/Stratis.SmartContracts.CLR/Loader/ContractAssembly.cs b/src/Stratis.SmartContracts.CLR/Loader/ContractAssembly.cs index 4e9103776f..908261d5e9 100644 --- a/src/Stratis.SmartContracts.CLR/Loader/ContractAssembly.cs +++ b/src/Stratis.SmartContracts.CLR/Loader/ContractAssembly.cs @@ -49,12 +49,11 @@ private Type GetDeployedType() x.CustomAttributes.Any(y => y.AttributeType == typeof(DeployAttribute))); } - public static bool IsContractType(Type typeDefinition) + private static bool IsContractType(Type typeDefinition) { return typeDefinition.IsClass && !typeDefinition.IsAbstract && - typeDefinition.BaseType != null && - typeDefinition.BaseType == typeof(SmartContract); + typeDefinition.IsSubclassOf(typeof(SmartContract)); } private Type GetObserverType()