Skip to content
Snippets Groups Projects
strategies.py 26 KiB
Newer Older
  • Learn to ignore specific revisions
  •         seen = set()
            for n in nodes.flatten():
                si = n.get_storage_index()
                if si in seen:
                    return False
                seen.add(si)
            return True
    
    
    Tom Prince's avatar
    Tom Prince committed
        return recursive(leaf_nodes(), directory_nodes,).filter(
    
            storage_indexes_are_distinct,
    
    
    
    def pass_counts():
        """
        Build integers usable as a number of passes to work on.  There is always
        at least one pass in a group and there are never "too many", whatever that
        means.
        """
        return integers(min_value=1, max_value=2 ** 8)
    
    
    
    def api_auth_tokens():
        """
        Build byte strings like those generated by Tahoe-LAFS for use as HTTP API
        authorization tokens.
        """
        return binary(min_size=32, max_size=32).map(b64encode)
    
    
    
    def ristretto_signing_keys():
        """
        Build byte strings holding base64-encoded Ristretto signing keys, perhaps
        with leading or trailing whitespace.
        """
    
    Tom Prince's avatar
    Tom Prince committed
        keys = sampled_from(
            [
                # A few legit keys
                b"mkQf85V2vyLQRUYuqRb+Ke6K+M9pOtXm4MslsuCdBgg=",
                b"6f93OIdZHHAmSIaRXDSIU1UcN+sbDAh41TRPb5DhrgI=",
                b"k58h8yPT18epw+EKMJhwHFfoM6r3TIExKm4efQHNBgM=",
                b"rbaAlWZ3NCnl5oZ9meviGfpLbyJpgpuiuFOX0rLnNwQ=",
            ]
        )
        whitespace = sampled_from(
            [
                # maybe no whitespace at all
                b""
                # or maybe some
                b" ",
                b"\t",
                b"\n",
                b"\r\n",
            ]
        )
    
    
        return builds(
            lambda leading, key, trailing: leading + key + trailing,
            whitespace,
            keys,
            whitespace,
        )