This repository was archived by the owner on Mar 10, 2020. It is now read-only.
  
  
  - 
                Notifications
    
You must be signed in to change notification settings  - Fork 105
 
chore: convert tests async await #547
          
     Closed
      
      
            PedroMiguelSS
  wants to merge
  26
  commits into
  feat/interface-tests
from
chore/convert-tests-async-await
  
      
      
   
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            26 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      18694bc
              
                chore: bitswap async/await refactor
              
              
                 fe10d34
              
                chore: block async/await refactor
              
              
                 729c944
              
                chore: bootstrap async/await refactor
              
              
                 dcde4fd
              
                chore: config async/await refactor
              
              
                 0a989a3
              
                chore: dht async/await refactor
              
              
                 53c0d60
              
                chore: files-mfs async/await refactor
              
              
                 a5e8194
              
                chore: files-regular async/await refactor
              
              
                 4a2a968
              
                chore: key async/await refactor
              
              
                 da306ee
              
                chore: miscellaneous async/await refactor
              
              
                 22db5a6
              
                chore: name async/await refactor
              
              
                 2b11917
              
                chore: name-pubsub async/await refactor
              
              
                 0124e76
              
                chore: object async/await refactor
              
              
                 c92e0cb
              
                chore: pin async/await refactor
              
              
                 2f09530
              
                chore: ping async/await refactor
              
              
                 cc75bb7
              
                chore: pubsub async/await refactor
              
              
                 570c86c
              
                chore: repo async/await refactor
              
              
                 b780517
              
                chore: stats async/await refactor
              
              
                 e2bb172
              
                chore: swarm async/await refactor
              
              
                 355d61e
              
                chore: remove delay util file in favor of 'delay' module
              
              
                 dcaf0a3
              
                chore: dag async/await refactor
              
              
                 d9812ec
              
                chore: convert missing object.get api to async/await syntax
              
              
                 91adca1
              
                chore: convert before function on files-mfs to async/await
              
              
                 d02e535
              
                chore: dedup existing promise-based tests
              
              
                 c1172c2
              
                chore: update assertion on failure tests
              
              
                 2b4fbf5
              
                chore: code review changes
              
              
                 8bd5541
              
                chore: more code review changes
              
              
                 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 | 
|---|---|---|
| @@ -1,36 +1,24 @@ | ||
| 'use strict' | ||
| 
     | 
||
| const until = require('async/until') | ||
| const pWhilst = require('p-whilst') | ||
| 
     | 
||
| function waitForWantlistKey (ipfs, key, opts, cb) { | ||
| if (typeof opts === 'function') { | ||
| cb = opts | ||
| opts = {} | ||
| } | ||
| 
     | 
||
| opts = opts || {} | ||
| function waitForWantlistKey (ipfs, key, opts = {}) { | ||
| opts.timeout = opts.timeout || 10000 | ||
| 
     | 
||
| let list = { Keys: [] } | ||
| 
     | 
||
| const start = Date.now() | ||
| const test = () => list.Keys.some(k => k['/'] === key) | ||
| const iteratee = (cb) => { | ||
| const test = () => !list.Keys.some(k => k['/'] === key) | ||
| 
     | 
||
| const iteratee = async () => { | ||
| if (Date.now() - start > opts.timeout) { | ||
| return cb(new Error(`Timed out waiting for ${key} in wantlist`)) | ||
| throw new Error(`Timed out waiting for ${key} in wantlist`) | ||
| } | ||
| ipfs.bitswap.wantlist(opts.peerId, (err, nextList) => { | ||
| if (err) return cb(err) | ||
| list = nextList | ||
| cb() | ||
| }) | ||
| 
     | 
||
| list = await ipfs.bitswap.wantlist(opts.peerId) | ||
| } | ||
| until(test, iteratee, (err) => { | ||
| if (err) { | ||
| return cb(err) | ||
| } | ||
| cb() | ||
| }) | ||
| 
     | 
||
| return pWhilst(test, iteratee) | ||
| } | ||
| 
     | 
||
| module.exports.waitForWantlistKey = waitForWantlistKey | 
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.