@@ -21,7 +21,8 @@ describe("Sector3DAOPriority", function () {
2121 const rewardToken = await SECTOR3 . deploy ( ) ;
2222 const epochDurationInDays = 7 ; // Weekly
2323 const epochBudget = ( 2.049 * 1e18 ) . toString ( ) ; // 2.049
24- const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget ) ;
24+ const gatingNFT = ethers . constants . AddressZero ;
25+ const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget , gatingNFT ) ;
2526
2627 return { sector3DAOPriority, owner, otherAccount, rewardToken } ;
2728 }
@@ -42,7 +43,8 @@ describe("Sector3DAOPriority", function () {
4243 const rewardToken = await SECTOR3 . deploy ( ) ;
4344 const epochDurationInDays = 14 ; // Biweekly
4445 const epochBudget = ( 2.049 * 1e18 ) . toString ( ) ; // 2.049
45- const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget ) ;
46+ const gatingNFT = ethers . constants . AddressZero ;
47+ const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget , gatingNFT ) ;
4648
4749 return { sector3DAOPriority, owner, otherAccount, rewardToken } ;
4850 }
@@ -63,11 +65,38 @@ describe("Sector3DAOPriority", function () {
6365 const rewardToken = await SECTOR3 . deploy ( ) ;
6466 const epochDurationInDays = 28 ; // Monthly
6567 const epochBudget = ( 2.049 * 1e18 ) . toString ( ) ; // 2.049
66- const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget ) ;
68+ const gatingNFT = ethers . constants . AddressZero ;
69+ const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget , gatingNFT ) ;
6770
6871 return { sector3DAOPriority, owner, otherAccount, rewardToken } ;
6972 }
7073
74+
75+ // We define a fixture to reuse the same setup in every test.
76+ // We use loadFixture to run this setup once, snapshot that state,
77+ // and reset Hardhat Network to that snapshot in every test.
78+ async function deployWeeklyFixtureWithNFTGating ( ) {
79+ console . log ( 'deployWeeklyFixtureWithNFTGating' )
80+
81+ // Contracts are deployed using the first signer/account by default
82+ const [ owner , otherAccount ] = await ethers . getSigners ( ) ;
83+ console . log ( 'owner.address:' , owner . address ) ;
84+ console . log ( 'otherAccount.address:' , otherAccount . address ) ;
85+
86+ const Sector3DAOPriority = await ethers . getContractFactory ( "Sector3DAOPriority" ) ;
87+ const dao = "0x96Bf89193E2A07720e42bA3AD736128a45537e63" ; // Sector#3
88+ const title = "Priority Title" ;
89+ const SECTOR3 = await ethers . getContractFactory ( "SECTOR3" ) ;
90+ const rewardToken = await SECTOR3 . deploy ( ) ;
91+ const epochDurationInDays = 7 ; // Weekly
92+ const epochBudget = ( 2.049 * 1e18 ) . toString ( ) ; // 2.049
93+ const Sector3Dove = await ethers . getContractFactory ( "Sector3Dove" ) ;
94+ const gatingNFT = await Sector3Dove . deploy ( ) ;
95+ const sector3DAOPriority = await Sector3DAOPriority . deploy ( dao , title , rewardToken . address , epochDurationInDays , epochBudget , gatingNFT . address ) ;
96+
97+ return { sector3DAOPriority, owner, otherAccount, rewardToken, gatingNFT } ;
98+ }
99+
71100
72101 describe ( "Deployment" , function ( ) {
73102 it ( "Should set the right DAO address" , async function ( ) {
@@ -413,6 +442,37 @@ describe("Sector3DAOPriority", function () {
413442 } ) ;
414443 } ) ;
415444
445+
446+ describe ( "NFT gating - addContribution2" , async function ( ) {
447+ it ( "should fail if NFT gating" , async function ( ) {
448+ const { sector3DAOPriority, owner } = await loadFixture ( deployWeeklyFixtureWithNFTGating ) ;
449+
450+ await expect ( sector3DAOPriority . addContribution2 (
451+ "Description (test)" ,
452+ "https://github.com/sector-3" ,
453+ 10 ,
454+ 3 // Alignment.Mostly
455+ ) ) . to . be . revertedWithCustomError (
456+ sector3DAOPriority ,
457+ "NoGatingNFTOwnership"
458+ )
459+ } ) ;
460+
461+ it ( "should succeed if NFT gating and account is NFT owner" , async function ( ) {
462+ const { sector3DAOPriority, owner, gatingNFT } = await loadFixture ( deployWeeklyFixtureWithNFTGating ) ;
463+
464+ await gatingNFT . safeMint ( owner . address ) ;
465+
466+ await sector3DAOPriority . addContribution2 (
467+ "Description (test)" ,
468+ "https://github.com/sector-3" ,
469+ 10 ,
470+ 3 // Alignment.Mostly
471+ ) ;
472+ expect ( await sector3DAOPriority . getContributionCount ( ) ) . to . equal ( 1 ) ;
473+ } ) ;
474+ } ) ;
475+
416476
417477 describe ( "getAllocationPercentage" , async function ( ) {
418478 it ( "Should be 100% if one contributor" , async function ( ) {
0 commit comments