@@ -35,6 +35,7 @@ describe('GNS', () => {
35
35
36
36
const tokens1000 = toGRT ( '1000' )
37
37
const tokens10000 = toGRT ( '10000' )
38
+ const tokens100000 = toGRT ( '100000' )
38
39
const withdrawalPercentage = 50000
39
40
let subgraph0 : Subgraph
40
41
let subgraph1 : Subgraph
@@ -69,21 +70,15 @@ describe('GNS', () => {
69
70
account : Account ,
70
71
graphAccount : string ,
71
72
subgraphNumber : number ,
72
- graphTokens : BigNumber ,
73
73
subgraphToPublish = subgraph0 , // Defaults to subgraph created in before()
74
74
) : Promise < ContractTransaction > => {
75
- const signals = await gns . tokensToNSignal ( graphAccount , subgraphNumber , graphTokens )
76
- const vSigEstimate = signals [ 0 ]
77
- const nSigEstimate = signals [ 1 ]
78
-
79
75
const tx = gns
80
76
. connect ( account . signer )
81
77
. publishNewSubgraph (
82
78
graphAccount ,
83
79
subgraphToPublish . subgraphDeploymentID ,
84
80
subgraphToPublish . versionMetadata ,
85
81
subgraphToPublish . subgraphMetadata ,
86
- graphTokens ,
87
82
)
88
83
await expect ( tx )
89
84
. emit ( gns , 'SubgraphPublished' )
@@ -102,17 +97,9 @@ describe('GNS', () => {
102
97
subgraphToPublish . subgraphMetadata ,
103
98
)
104
99
105
- const tokensVSig = await getTokensAndVSig ( subgraph0 . subgraphDeploymentID )
106
- const tokensAfter = tokensVSig [ 0 ]
107
- const vSigCuration = tokensVSig [ 1 ]
108
- expect ( graphTokens ) . eq ( tokensAfter )
109
-
110
100
const pool = await gns . nameSignals ( graphAccount , subgraphNumber )
111
- const vSigPool = pool [ 0 ]
112
- const nSig = pool [ 1 ]
113
- expect ( vSigCuration ) . eq ( vSigPool ) . eq ( vSigEstimate )
114
- expect ( nSigEstimate ) . eq ( nSig )
115
-
101
+ const reserveRatio = pool [ 3 ]
102
+ expect ( reserveRatio ) . eq ( 1000000 )
116
103
return tx
117
104
}
118
105
const publishNewVersion = async (
@@ -332,7 +319,7 @@ describe('GNS', () => {
332
319
const tx = gns . connect ( account . signer ) . mintNSignal ( graphAccount , subgraphNumber0 , graphTokens )
333
320
await expect ( tx )
334
321
. emit ( gns , 'NSignalMinted' )
335
- . withArgs ( graphAccount , subgraphNumber0 , other . address , nSigEstimate , vSigEstimate )
322
+ . withArgs ( graphAccount , subgraphNumber0 , account . address , nSigEstimate , vSigEstimate )
336
323
337
324
const tokensVSig = await getTokensAndVSig ( subgraph0 . subgraphDeploymentID )
338
325
const tokensAfter = tokensVSig [ 0 ]
@@ -462,12 +449,12 @@ describe('GNS', () => {
462
449
subgraph1 = createSubgraph ( me , '1' )
463
450
defaultName = createDefaultName ( 'graph' )
464
451
// Give some funds to the signers and approve gns contract to use funds on signers behalf
465
- await grt . connect ( governor . signer ) . mint ( me . address , tokens10000 )
466
- await grt . connect ( governor . signer ) . mint ( other . address , tokens10000 )
467
- await grt . connect ( me . signer ) . approve ( gns . address , tokens10000 )
468
- await grt . connect ( me . signer ) . approve ( curation . address , tokens10000 )
469
- await grt . connect ( other . signer ) . approve ( gns . address , tokens10000 )
470
- await grt . connect ( other . signer ) . approve ( curation . address , tokens10000 )
452
+ await grt . connect ( governor . signer ) . mint ( me . address , tokens100000 )
453
+ await grt . connect ( governor . signer ) . mint ( other . address , tokens100000 )
454
+ await grt . connect ( me . signer ) . approve ( gns . address , tokens100000 )
455
+ await grt . connect ( me . signer ) . approve ( curation . address , tokens100000 )
456
+ await grt . connect ( other . signer ) . approve ( gns . address , tokens100000 )
457
+ await grt . connect ( other . signer ) . approve ( curation . address , tokens100000 )
471
458
472
459
// Update withdrawal fee to test the functionality of it in disableNameSignal()
473
460
await curation . connect ( governor . signer ) . setWithdrawalFeePercentage ( withdrawalPercentage )
@@ -517,22 +504,22 @@ describe('GNS', () => {
517
504
describe ( 'isPublished' , function ( ) {
518
505
it ( 'should return if the subgraph is published' , async function ( ) {
519
506
expect ( await gns . isPublished ( subgraph0 . graphAccount . address , 0 ) ) . eq ( false )
520
- await publishNewSubgraph ( me , me . address , 0 , tokens1000 )
507
+ await publishNewSubgraph ( me , me . address , 0 )
521
508
expect ( await gns . isPublished ( subgraph0 . graphAccount . address , 0 ) ) . eq ( true )
522
509
} )
523
510
} )
524
511
525
512
describe ( 'publishNewSubgraph' , async function ( ) {
526
513
it ( 'should publish a new subgraph and first version with it' , async function ( ) {
527
- await publishNewSubgraph ( me , me . address , 0 , tokens1000 )
514
+ await publishNewSubgraph ( me , me . address , 0 )
528
515
// State updated
529
516
const deploymentID = await gns . subgraphs ( subgraph0 . graphAccount . address , 0 )
530
517
expect ( subgraph0 . subgraphDeploymentID ) . eq ( deploymentID )
531
518
} )
532
519
533
520
it ( 'should publish a new subgraph with an incremented value' , async function ( ) {
534
- await publishNewSubgraph ( me , me . address , 0 , tokens1000 )
535
- await publishNewSubgraph ( me , me . address , 1 , tokens1000 , subgraph1 )
521
+ await publishNewSubgraph ( me , me . address , 0 )
522
+ await publishNewSubgraph ( me , me . address , 1 , subgraph1 )
536
523
const deploymentID = await gns . subgraphs ( subgraph1 . graphAccount . address , 1 )
537
524
expect ( subgraph1 . subgraphDeploymentID ) . eq ( deploymentID )
538
525
} )
@@ -545,7 +532,6 @@ describe('GNS', () => {
545
532
ethers . constants . HashZero ,
546
533
subgraph0 . versionMetadata ,
547
534
subgraph0 . subgraphMetadata ,
548
- tokens1000 ,
549
535
)
550
536
await expect ( tx ) . revertedWith ( 'GNS: Only graph account owner can call' )
551
537
} )
@@ -558,15 +544,15 @@ describe('GNS', () => {
558
544
ethers . constants . HashZero ,
559
545
subgraph0 . versionMetadata ,
560
546
subgraph0 . subgraphMetadata ,
561
- tokens1000 ,
562
547
)
563
548
await expect ( tx ) . revertedWith ( 'GNS: Cannot set deploymentID to 0 in publish' )
564
549
} )
565
550
} )
566
551
567
552
describe ( 'publishNewVersion' , async function ( ) {
568
553
beforeEach ( async ( ) => {
569
- await publishNewSubgraph ( me , me . address , 0 , tokens1000 )
554
+ await publishNewSubgraph ( me , me . address , 0 )
555
+ await mintNSignal ( me , me . address , 0 , tokens10000 )
570
556
} )
571
557
it ( 'should publish a new version on an existing subgraph' , async function ( ) {
572
558
await publishNewVersion ( me , me . address , 0 , subgraph1 )
@@ -655,7 +641,8 @@ describe('GNS', () => {
655
641
656
642
describe ( 'deprecateSubgraph' , async function ( ) {
657
643
beforeEach ( async ( ) => {
658
- await publishNewSubgraph ( me , me . address , 0 , tokens1000 )
644
+ await publishNewSubgraph ( me , me . address , 0 )
645
+ await mintNSignal ( me , me . address , 0 , tokens10000 )
659
646
} )
660
647
it ( 'should deprecate a subgraph' , async function ( ) {
661
648
await deprecateSubgraph ( me , me . address , 0 )
@@ -693,11 +680,11 @@ describe('GNS', () => {
693
680
const subgraphNumber0 = 0
694
681
describe ( 'mintNSignal()' , async function ( ) {
695
682
it ( 'should deposit into the name signal curve' , async function ( ) {
696
- await publishNewSubgraph ( me , me . address , subgraphNumber0 , tokens1000 )
683
+ await publishNewSubgraph ( me , me . address , subgraphNumber0 )
697
684
await mintNSignal ( other , me . address , subgraphNumber0 , tokens10000 )
698
685
} )
699
686
it ( 'should fail when name signal is disabled' , async function ( ) {
700
- await publishNewSubgraph ( me , me . address , subgraphNumber0 , tokens1000 )
687
+ await publishNewSubgraph ( me , me . address , subgraphNumber0 )
701
688
await deprecateSubgraph ( me , me . address , 0 )
702
689
const tx = gns . connect ( me . signer ) . mintNSignal ( me . address , subgraphNumber0 , tokens1000 )
703
690
await expect ( tx ) . revertedWith ( 'GNS: Cannot be disabled' )
@@ -709,7 +696,7 @@ describe('GNS', () => {
709
696
} )
710
697
describe ( 'burnNSignal()' , async function ( ) {
711
698
beforeEach ( async ( ) => {
712
- await publishNewSubgraph ( me , me . address , subgraphNumber0 , tokens1000 )
699
+ await publishNewSubgraph ( me , me . address , subgraphNumber0 )
713
700
await mintNSignal ( other , me . address , subgraphNumber0 , tokens10000 )
714
701
} )
715
702
it ( 'should withdraw from the name signal curve' , async function ( ) {
@@ -733,7 +720,7 @@ describe('GNS', () => {
733
720
} )
734
721
describe ( 'withdraw()' , async function ( ) {
735
722
beforeEach ( async ( ) => {
736
- await publishNewSubgraph ( me , me . address , subgraphNumber0 , tokens1000 )
723
+ await publishNewSubgraph ( me , me . address , subgraphNumber0 )
737
724
await mintNSignal ( other , me . address , subgraphNumber0 , tokens10000 )
738
725
} )
739
726
it ( 'should withdraw GRT from a disabled name signal' , async function ( ) {
@@ -747,13 +734,11 @@ describe('GNS', () => {
747
734
it ( 'should fail when there is no more GRT to withdraw' , async function ( ) {
748
735
await deprecateSubgraph ( me , me . address , 0 )
749
736
await withdraw ( other , me . address , subgraphNumber0 )
750
- await withdraw ( me , me . address , subgraphNumber0 )
751
737
const tx = gns . connect ( other . signer ) . withdraw ( me . address , subgraphNumber0 )
752
738
await expect ( tx ) . revertedWith ( 'GNS: No more GRT to withdraw' )
753
739
} )
754
740
it ( 'should fail if the curator has no nSignal' , async function ( ) {
755
741
await deprecateSubgraph ( me , me . address , 0 )
756
- await withdraw ( me , me . address , subgraphNumber0 )
757
742
const tx = gns . connect ( me . signer ) . withdraw ( me . address , subgraphNumber0 )
758
743
await expect ( tx ) . revertedWith ( 'GNS: Curator must have some nSignal to withdraw GRT' )
759
744
} )
0 commit comments