1
1
import { ethers } from "hardhat" ;
2
- import { Signer } from "ethers" ;
3
2
import { expect } from "chai" ;
4
3
import {
5
4
CodeHashDistribution ,
6
5
CodeHashDistribution__factory ,
7
6
CodeIndex ,
8
7
} from "../../types" ;
9
- import hre , { deployments } from "hardhat" ;
8
+ import { deployments } from "hardhat" ;
10
9
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers" ;
11
10
import utils from "../utils" ;
12
11
@@ -36,7 +35,9 @@ describe("CloneHashDistribution", function () {
36
35
const codeHash = ethers . utils . keccak256 ( code ) ;
37
36
const codeHashDistribution = ( await CodeHashDistribution . deploy (
38
37
codeHash ,
39
- ethers . utils . formatBytes32String ( "DiamondProxy" )
38
+ ethers . utils . formatBytes32String ( "DiamondProxy" ) ,
39
+ ethers . utils . formatBytes32String ( "testDistribution" ) ,
40
+ 0
40
41
) ) as CodeHashDistribution ;
41
42
expect ( await codeHashDistribution . instantiate ( ) ) . to . emit (
42
43
codeHashDistribution ,
@@ -54,7 +55,9 @@ describe("CloneHashDistribution", function () {
54
55
const codeHash = ethers . utils . keccak256 ( code ) ;
55
56
const codeHashDistribution = ( await CodeHashDistribution . deploy (
56
57
codeHash ,
57
- ethers . utils . formatBytes32String ( "DiamondProxy" )
58
+ ethers . utils . formatBytes32String ( "DiamondProxy" ) ,
59
+ ethers . utils . formatBytes32String ( "testDistribution" ) ,
60
+ 0
58
61
) ) as CodeHashDistribution ;
59
62
const receipt = await ( await codeHashDistribution . instantiate ( ) ) . wait ( ) ;
60
63
@@ -70,4 +73,26 @@ describe("CloneHashDistribution", function () {
70
73
testFacet . address . slice ( 2 ) . toLowerCase ( )
71
74
) ;
72
75
} ) ;
76
+ it ( "returns contract name and version" , async function ( ) {
77
+ const TestFacet = await ethers . getContractFactory ( "TestFacet" ) ;
78
+ const testFacet = await TestFacet . deploy ( ) ;
79
+ codeIndex . register ( testFacet . address ) ;
80
+ const CodeHashDistribution = ( await ethers . getContractFactory (
81
+ "CodeHashDistribution"
82
+ ) ) as CodeHashDistribution__factory ;
83
+ const code = await testFacet . provider . getCode ( testFacet . address ) ;
84
+ const codeHash = ethers . utils . keccak256 ( code ) ;
85
+ const codeHashDistribution = ( await CodeHashDistribution . deploy (
86
+ codeHash ,
87
+ ethers . utils . formatBytes32String ( "DiamondProxy" ) ,
88
+ ethers . utils . formatBytes32String ( "testDistribution" ) ,
89
+ 0
90
+ ) ) as CodeHashDistribution ;
91
+
92
+ const { src, name, version } = await codeHashDistribution . get ( ) ;
93
+ expect ( ethers . utils . parseBytes32String ( name ) ) . to . be . equal (
94
+ "testDistribution"
95
+ ) ;
96
+ expect ( version ) . to . be . equal ( 0 ) ;
97
+ } ) ;
73
98
} ) ;
0 commit comments